Drawing lines to nearest pointPostGIS nearest points with ST_Distance, kNNFinding point closest to point on near feature?Joining attributes from nearest point in QGIS?Need to generate ids to connect points and polygonsSelecting nearest lines to point layer in QGIS?Nearest neighbor analysis, write multiple columns to tableFind distance from points along linesGRASS v.net.iso does not include all linesCalculating distances between student homes and schools using QGIS?Minimum distance from points to nearest line among multiple lines shapefileLines between corresponding points from two shapefilesQGIS distance from a cell center to the nearest point

Why was the Ancient One so hesitant to teach Dr. Strange the art of sorcery?

Early arrival in Australia, early hotel check in not available

Ex-manager wants to stay in touch, I don't want to

Can I make ravioli dough with only all-purpose flour or do I NEED semolina flour?

How can this pool heater gas line be disconnected?

Can you book a one-way ticket to the UK on a visa?

Extrude the faces of a cube symmetrically along XYZ

Does kinetic energy warp spacetime?

Why was this sacrifice sufficient?

How to compact two the parabol commands in the following example?

Why does getw return -1 when trying to read a character?

Was this character’s old age look CGI or make-up?

Run script for 10 times until meets the condition, but break the loop if it meets the condition during iteration

Noob at soldering, can anyone explain why my circuit won't work?

How can I answer high-school writing prompts without sounding weird and fake?

Why was castling bad for white in this game, and engine strongly prefered trading queens?

What are the implications of the new alleged key recovery attack preprint on SIMON?

How to use structured binding in an array passed as arg to some function?

How did Thanos not realise this had happened at the end of Endgame?

Why doesn't Rocket Lab use a solid stage?

Usefulness of complex chord names?

What's special about a Bunsen burner?

How to minimise the cost of guessing a number in a high/low guess game?

Exception propagation: When should I catch exceptions?



Drawing lines to nearest point


PostGIS nearest points with ST_Distance, kNNFinding point closest to point on near feature?Joining attributes from nearest point in QGIS?Need to generate ids to connect points and polygonsSelecting nearest lines to point layer in QGIS?Nearest neighbor analysis, write multiple columns to tableFind distance from points along linesGRASS v.net.iso does not include all linesCalculating distances between student homes and schools using QGIS?Minimum distance from points to nearest line among multiple lines shapefileLines between corresponding points from two shapefilesQGIS distance from a cell center to the nearest point






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








5















I have two point layers, one with telecom towers and another with secondary schools. I have used the NN-join plugin to find the nearest tower from each school, and calculated the distance between. The result is in a vector layer, with separate columns for the tower and school names.



How can one draw lines between the pairs of points?










share|improve this question







New contributor



olofhess is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 2





    Do the pairs of points have a feature in common? (for example an ID) It can used as a key to link them...

    – gianfranco di pietro
    10 hours ago











  • No, they have separate IDs, i.e. each school and tower has a separate name, and (obviously) separate lat/long. But since each pair is uniquely defined on each row in the table, perhaps I can create a unique ID by concatenating school name and tower name?

    – olofhess
    7 hours ago

















5















I have two point layers, one with telecom towers and another with secondary schools. I have used the NN-join plugin to find the nearest tower from each school, and calculated the distance between. The result is in a vector layer, with separate columns for the tower and school names.



How can one draw lines between the pairs of points?










share|improve this question







New contributor



olofhess is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 2





    Do the pairs of points have a feature in common? (for example an ID) It can used as a key to link them...

    – gianfranco di pietro
    10 hours ago











  • No, they have separate IDs, i.e. each school and tower has a separate name, and (obviously) separate lat/long. But since each pair is uniquely defined on each row in the table, perhaps I can create a unique ID by concatenating school name and tower name?

    – olofhess
    7 hours ago













5












5








5








I have two point layers, one with telecom towers and another with secondary schools. I have used the NN-join plugin to find the nearest tower from each school, and calculated the distance between. The result is in a vector layer, with separate columns for the tower and school names.



How can one draw lines between the pairs of points?










share|improve this question







New contributor



olofhess is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have two point layers, one with telecom towers and another with secondary schools. I have used the NN-join plugin to find the nearest tower from each school, and calculated the distance between. The result is in a vector layer, with separate columns for the tower and school names.



How can one draw lines between the pairs of points?







qgis






share|improve this question







New contributor



olofhess is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question







New contributor



olofhess is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question






New contributor



olofhess is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 10 hours ago









olofhessolofhess

262




262




New contributor



olofhess is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




olofhess is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









  • 2





    Do the pairs of points have a feature in common? (for example an ID) It can used as a key to link them...

    – gianfranco di pietro
    10 hours ago











  • No, they have separate IDs, i.e. each school and tower has a separate name, and (obviously) separate lat/long. But since each pair is uniquely defined on each row in the table, perhaps I can create a unique ID by concatenating school name and tower name?

    – olofhess
    7 hours ago












  • 2





    Do the pairs of points have a feature in common? (for example an ID) It can used as a key to link them...

    – gianfranco di pietro
    10 hours ago











  • No, they have separate IDs, i.e. each school and tower has a separate name, and (obviously) separate lat/long. But since each pair is uniquely defined on each row in the table, perhaps I can create a unique ID by concatenating school name and tower name?

    – olofhess
    7 hours ago







2




2





Do the pairs of points have a feature in common? (for example an ID) It can used as a key to link them...

– gianfranco di pietro
10 hours ago





Do the pairs of points have a feature in common? (for example an ID) It can used as a key to link them...

– gianfranco di pietro
10 hours ago













No, they have separate IDs, i.e. each school and tower has a separate name, and (obviously) separate lat/long. But since each pair is uniquely defined on each row in the table, perhaps I can create a unique ID by concatenating school name and tower name?

– olofhess
7 hours ago





No, they have separate IDs, i.e. each school and tower has a separate name, and (obviously) separate lat/long. But since each pair is uniquely defined on each row in the table, perhaps I can create a unique ID by concatenating school name and tower name?

– olofhess
7 hours ago










2 Answers
2






active

oldest

votes


















4














This should be possible without any plugin using the default Processing tools, particularly Distance to nearest hub:



enter image description here



https://docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/vectoranalysis.html#qgisdistancetonearesthublinetohub



enter image description here






share|improve this answer
































    3















    Tested on QGIS 2.18 and QGIS 3.4




    I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...



    Let's assume we have eight features in "school" (blue squares) and five in "tower" (orange circles) accordingly, see image below.



    Example



    With the following Query, it is possible to achieve the result



    SELECT s.Name AS SName, t.Name AS TName,
    make_line(s.geometry, t.geometry),
    ROUND(MIN(ST_Distance(s.geometry, t.geometry)),2) AS distance,
    s.id || '_' || t.id AS uniqueid
    FROM school AS s, tower AS t
    GROUP BY s.Name
    ORDER BY distance DESC


    The output Virtual Layer will generate shortest lines between schools and towers including the following attributes 'school name', 'closest tower name', 'distance to the closest tower' and 'unique id'.



    Result




    References:



    • Finding point closest to point on near feature?

    • PostGIS nearest points with ST_Distance, kNN





    share|improve this answer

























      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "79"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );






      olofhess is a new contributor. Be nice, and check out our Code of Conduct.









      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f322474%2fdrawing-lines-to-nearest-point%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      4














      This should be possible without any plugin using the default Processing tools, particularly Distance to nearest hub:



      enter image description here



      https://docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/vectoranalysis.html#qgisdistancetonearesthublinetohub



      enter image description here






      share|improve this answer





























        4














        This should be possible without any plugin using the default Processing tools, particularly Distance to nearest hub:



        enter image description here



        https://docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/vectoranalysis.html#qgisdistancetonearesthublinetohub



        enter image description here






        share|improve this answer



























          4












          4








          4







          This should be possible without any plugin using the default Processing tools, particularly Distance to nearest hub:



          enter image description here



          https://docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/vectoranalysis.html#qgisdistancetonearesthublinetohub



          enter image description here






          share|improve this answer















          This should be possible without any plugin using the default Processing tools, particularly Distance to nearest hub:



          enter image description here



          https://docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/vectoranalysis.html#qgisdistancetonearesthublinetohub



          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 22 mins ago

























          answered 3 hours ago









          underdarkunderdark

          69.6k13179351




          69.6k13179351























              3















              Tested on QGIS 2.18 and QGIS 3.4




              I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...



              Let's assume we have eight features in "school" (blue squares) and five in "tower" (orange circles) accordingly, see image below.



              Example



              With the following Query, it is possible to achieve the result



              SELECT s.Name AS SName, t.Name AS TName,
              make_line(s.geometry, t.geometry),
              ROUND(MIN(ST_Distance(s.geometry, t.geometry)),2) AS distance,
              s.id || '_' || t.id AS uniqueid
              FROM school AS s, tower AS t
              GROUP BY s.Name
              ORDER BY distance DESC


              The output Virtual Layer will generate shortest lines between schools and towers including the following attributes 'school name', 'closest tower name', 'distance to the closest tower' and 'unique id'.



              Result




              References:



              • Finding point closest to point on near feature?

              • PostGIS nearest points with ST_Distance, kNN





              share|improve this answer





























                3















                Tested on QGIS 2.18 and QGIS 3.4




                I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...



                Let's assume we have eight features in "school" (blue squares) and five in "tower" (orange circles) accordingly, see image below.



                Example



                With the following Query, it is possible to achieve the result



                SELECT s.Name AS SName, t.Name AS TName,
                make_line(s.geometry, t.geometry),
                ROUND(MIN(ST_Distance(s.geometry, t.geometry)),2) AS distance,
                s.id || '_' || t.id AS uniqueid
                FROM school AS s, tower AS t
                GROUP BY s.Name
                ORDER BY distance DESC


                The output Virtual Layer will generate shortest lines between schools and towers including the following attributes 'school name', 'closest tower name', 'distance to the closest tower' and 'unique id'.



                Result




                References:



                • Finding point closest to point on near feature?

                • PostGIS nearest points with ST_Distance, kNN





                share|improve this answer



























                  3












                  3








                  3








                  Tested on QGIS 2.18 and QGIS 3.4




                  I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...



                  Let's assume we have eight features in "school" (blue squares) and five in "tower" (orange circles) accordingly, see image below.



                  Example



                  With the following Query, it is possible to achieve the result



                  SELECT s.Name AS SName, t.Name AS TName,
                  make_line(s.geometry, t.geometry),
                  ROUND(MIN(ST_Distance(s.geometry, t.geometry)),2) AS distance,
                  s.id || '_' || t.id AS uniqueid
                  FROM school AS s, tower AS t
                  GROUP BY s.Name
                  ORDER BY distance DESC


                  The output Virtual Layer will generate shortest lines between schools and towers including the following attributes 'school name', 'closest tower name', 'distance to the closest tower' and 'unique id'.



                  Result




                  References:



                  • Finding point closest to point on near feature?

                  • PostGIS nearest points with ST_Distance, kNN





                  share|improve this answer
















                  Tested on QGIS 2.18 and QGIS 3.4




                  I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...



                  Let's assume we have eight features in "school" (blue squares) and five in "tower" (orange circles) accordingly, see image below.



                  Example



                  With the following Query, it is possible to achieve the result



                  SELECT s.Name AS SName, t.Name AS TName,
                  make_line(s.geometry, t.geometry),
                  ROUND(MIN(ST_Distance(s.geometry, t.geometry)),2) AS distance,
                  s.id || '_' || t.id AS uniqueid
                  FROM school AS s, tower AS t
                  GROUP BY s.Name
                  ORDER BY distance DESC


                  The output Virtual Layer will generate shortest lines between schools and towers including the following attributes 'school name', 'closest tower name', 'distance to the closest tower' and 'unique id'.



                  Result




                  References:



                  • Finding point closest to point on near feature?

                  • PostGIS nearest points with ST_Distance, kNN






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 hours ago

























                  answered 2 hours ago









                  TarasTaras

                  2,4753830




                  2,4753830




















                      olofhess is a new contributor. Be nice, and check out our Code of Conduct.









                      draft saved

                      draft discarded


















                      olofhess is a new contributor. Be nice, and check out our Code of Conduct.












                      olofhess is a new contributor. Be nice, and check out our Code of Conduct.











                      olofhess is a new contributor. Be nice, and check out our Code of Conduct.














                      Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f322474%2fdrawing-lines-to-nearest-point%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown