Projecting points on line and calculating distance from line start












3















I have




  • a vector layer with a number of points which correspond to magnetic targets

  • axis retrieved from AutoCAD


The task is to project the points on the axis and then calculate the distance of each projected point from the start of the axis. Ideally, I would like the calculated distance to be on the same table as the points so I can know which point each distance refers to.



Moreover, it would be nice to know the perpendicular distance of each point from the reference axis. A picture of the above problem is also presented below.



Problem_example










share|improve this question





























    3















    I have




    • a vector layer with a number of points which correspond to magnetic targets

    • axis retrieved from AutoCAD


    The task is to project the points on the axis and then calculate the distance of each projected point from the start of the axis. Ideally, I would like the calculated distance to be on the same table as the points so I can know which point each distance refers to.



    Moreover, it would be nice to know the perpendicular distance of each point from the reference axis. A picture of the above problem is also presented below.



    Problem_example










    share|improve this question



























      3












      3








      3


      3






      I have




      • a vector layer with a number of points which correspond to magnetic targets

      • axis retrieved from AutoCAD


      The task is to project the points on the axis and then calculate the distance of each projected point from the start of the axis. Ideally, I would like the calculated distance to be on the same table as the points so I can know which point each distance refers to.



      Moreover, it would be nice to know the perpendicular distance of each point from the reference axis. A picture of the above problem is also presented below.



      Problem_example










      share|improve this question
















      I have




      • a vector layer with a number of points which correspond to magnetic targets

      • axis retrieved from AutoCAD


      The task is to project the points on the axis and then calculate the distance of each projected point from the start of the axis. Ideally, I would like the calculated distance to be on the same table as the points so I can know which point each distance refers to.



      Moreover, it would be nice to know the perpendicular distance of each point from the reference axis. A picture of the above problem is also presented below.



      Problem_example







      qgis point projection-mathematics






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 10 at 12:52









      Taras

      2,0192624




      2,0192624










      asked Jan 10 at 11:07









      PandPand

      214




      214






















          1 Answer
          1






          active

          oldest

          votes


















          4














          Start the Field Calculator on your point layer's attribute table.



          Create a new field by an expression below:



          line_locate_point(geometry:=geometry(get_feature('NaMy_FSR', 'id', '1')), point:=$geometry)


          Assuming:




          • Your line layer name is : NaMy_FSR

          • The line has an attribute value 1 in the 'id' field. (You can use any field to distinguish the line).




          [EDIT]



          As to the distance the perpendicular distance of each point from the reference axis;



          Not sure if this works, but will you try:



          distance(closest_point(geometry(get_feature(‘NaMy_FSR’, ‘id’, ‘1’)), geometry), $geometry)


          [revision]



          distance(closest_point(geometry(get_feature(‘NaMy_FSR’, ‘id’, ‘1’)), $geometry), $geometry)





          share|improve this answer


























          • Is there a way to obtain the projection distance from the line ?

            – Pand
            Jan 10 at 12:28











          • Hi @stamatis Yes, I think it is possible. Will you post a new question or edit your current question to include this additional requirement?

            – Kazuhito
            Jan 10 at 12:38











          • Question edited. Looking forward for the answer :)

            – Pand
            Jan 10 at 12:47











          • @stamatis Added another syntax in [EDIT] section. Hopefully it works, but other specialists at this board may help you better.

            – Kazuhito
            Jan 10 at 12:53






          • 1





            @stamatis Both questions are interesting, definitely. Will you post them as new questions? For the first one, I recommend to look into azimuth() function. I have no idea about the latter one, which would require experts' help.

            – Kazuhito
            Jan 10 at 13:31













          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f308201%2fprojecting-points-on-line-and-calculating-distance-from-line-start%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          Start the Field Calculator on your point layer's attribute table.



          Create a new field by an expression below:



          line_locate_point(geometry:=geometry(get_feature('NaMy_FSR', 'id', '1')), point:=$geometry)


          Assuming:




          • Your line layer name is : NaMy_FSR

          • The line has an attribute value 1 in the 'id' field. (You can use any field to distinguish the line).




          [EDIT]



          As to the distance the perpendicular distance of each point from the reference axis;



          Not sure if this works, but will you try:



          distance(closest_point(geometry(get_feature(‘NaMy_FSR’, ‘id’, ‘1’)), geometry), $geometry)


          [revision]



          distance(closest_point(geometry(get_feature(‘NaMy_FSR’, ‘id’, ‘1’)), $geometry), $geometry)





          share|improve this answer


























          • Is there a way to obtain the projection distance from the line ?

            – Pand
            Jan 10 at 12:28











          • Hi @stamatis Yes, I think it is possible. Will you post a new question or edit your current question to include this additional requirement?

            – Kazuhito
            Jan 10 at 12:38











          • Question edited. Looking forward for the answer :)

            – Pand
            Jan 10 at 12:47











          • @stamatis Added another syntax in [EDIT] section. Hopefully it works, but other specialists at this board may help you better.

            – Kazuhito
            Jan 10 at 12:53






          • 1





            @stamatis Both questions are interesting, definitely. Will you post them as new questions? For the first one, I recommend to look into azimuth() function. I have no idea about the latter one, which would require experts' help.

            – Kazuhito
            Jan 10 at 13:31


















          4














          Start the Field Calculator on your point layer's attribute table.



          Create a new field by an expression below:



          line_locate_point(geometry:=geometry(get_feature('NaMy_FSR', 'id', '1')), point:=$geometry)


          Assuming:




          • Your line layer name is : NaMy_FSR

          • The line has an attribute value 1 in the 'id' field. (You can use any field to distinguish the line).




          [EDIT]



          As to the distance the perpendicular distance of each point from the reference axis;



          Not sure if this works, but will you try:



          distance(closest_point(geometry(get_feature(‘NaMy_FSR’, ‘id’, ‘1’)), geometry), $geometry)


          [revision]



          distance(closest_point(geometry(get_feature(‘NaMy_FSR’, ‘id’, ‘1’)), $geometry), $geometry)





          share|improve this answer


























          • Is there a way to obtain the projection distance from the line ?

            – Pand
            Jan 10 at 12:28











          • Hi @stamatis Yes, I think it is possible. Will you post a new question or edit your current question to include this additional requirement?

            – Kazuhito
            Jan 10 at 12:38











          • Question edited. Looking forward for the answer :)

            – Pand
            Jan 10 at 12:47











          • @stamatis Added another syntax in [EDIT] section. Hopefully it works, but other specialists at this board may help you better.

            – Kazuhito
            Jan 10 at 12:53






          • 1





            @stamatis Both questions are interesting, definitely. Will you post them as new questions? For the first one, I recommend to look into azimuth() function. I have no idea about the latter one, which would require experts' help.

            – Kazuhito
            Jan 10 at 13:31
















          4












          4








          4







          Start the Field Calculator on your point layer's attribute table.



          Create a new field by an expression below:



          line_locate_point(geometry:=geometry(get_feature('NaMy_FSR', 'id', '1')), point:=$geometry)


          Assuming:




          • Your line layer name is : NaMy_FSR

          • The line has an attribute value 1 in the 'id' field. (You can use any field to distinguish the line).




          [EDIT]



          As to the distance the perpendicular distance of each point from the reference axis;



          Not sure if this works, but will you try:



          distance(closest_point(geometry(get_feature(‘NaMy_FSR’, ‘id’, ‘1’)), geometry), $geometry)


          [revision]



          distance(closest_point(geometry(get_feature(‘NaMy_FSR’, ‘id’, ‘1’)), $geometry), $geometry)





          share|improve this answer















          Start the Field Calculator on your point layer's attribute table.



          Create a new field by an expression below:



          line_locate_point(geometry:=geometry(get_feature('NaMy_FSR', 'id', '1')), point:=$geometry)


          Assuming:




          • Your line layer name is : NaMy_FSR

          • The line has an attribute value 1 in the 'id' field. (You can use any field to distinguish the line).




          [EDIT]



          As to the distance the perpendicular distance of each point from the reference axis;



          Not sure if this works, but will you try:



          distance(closest_point(geometry(get_feature(‘NaMy_FSR’, ‘id’, ‘1’)), geometry), $geometry)


          [revision]



          distance(closest_point(geometry(get_feature(‘NaMy_FSR’, ‘id’, ‘1’)), $geometry), $geometry)






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 10 at 13:14

























          answered Jan 10 at 11:20









          KazuhitoKazuhito

          15.2k31677




          15.2k31677













          • Is there a way to obtain the projection distance from the line ?

            – Pand
            Jan 10 at 12:28











          • Hi @stamatis Yes, I think it is possible. Will you post a new question or edit your current question to include this additional requirement?

            – Kazuhito
            Jan 10 at 12:38











          • Question edited. Looking forward for the answer :)

            – Pand
            Jan 10 at 12:47











          • @stamatis Added another syntax in [EDIT] section. Hopefully it works, but other specialists at this board may help you better.

            – Kazuhito
            Jan 10 at 12:53






          • 1





            @stamatis Both questions are interesting, definitely. Will you post them as new questions? For the first one, I recommend to look into azimuth() function. I have no idea about the latter one, which would require experts' help.

            – Kazuhito
            Jan 10 at 13:31





















          • Is there a way to obtain the projection distance from the line ?

            – Pand
            Jan 10 at 12:28











          • Hi @stamatis Yes, I think it is possible. Will you post a new question or edit your current question to include this additional requirement?

            – Kazuhito
            Jan 10 at 12:38











          • Question edited. Looking forward for the answer :)

            – Pand
            Jan 10 at 12:47











          • @stamatis Added another syntax in [EDIT] section. Hopefully it works, but other specialists at this board may help you better.

            – Kazuhito
            Jan 10 at 12:53






          • 1





            @stamatis Both questions are interesting, definitely. Will you post them as new questions? For the first one, I recommend to look into azimuth() function. I have no idea about the latter one, which would require experts' help.

            – Kazuhito
            Jan 10 at 13:31



















          Is there a way to obtain the projection distance from the line ?

          – Pand
          Jan 10 at 12:28





          Is there a way to obtain the projection distance from the line ?

          – Pand
          Jan 10 at 12:28













          Hi @stamatis Yes, I think it is possible. Will you post a new question or edit your current question to include this additional requirement?

          – Kazuhito
          Jan 10 at 12:38





          Hi @stamatis Yes, I think it is possible. Will you post a new question or edit your current question to include this additional requirement?

          – Kazuhito
          Jan 10 at 12:38













          Question edited. Looking forward for the answer :)

          – Pand
          Jan 10 at 12:47





          Question edited. Looking forward for the answer :)

          – Pand
          Jan 10 at 12:47













          @stamatis Added another syntax in [EDIT] section. Hopefully it works, but other specialists at this board may help you better.

          – Kazuhito
          Jan 10 at 12:53





          @stamatis Added another syntax in [EDIT] section. Hopefully it works, but other specialists at this board may help you better.

          – Kazuhito
          Jan 10 at 12:53




          1




          1





          @stamatis Both questions are interesting, definitely. Will you post them as new questions? For the first one, I recommend to look into azimuth() function. I have no idea about the latter one, which would require experts' help.

          – Kazuhito
          Jan 10 at 13:31







          @stamatis Both questions are interesting, definitely. Will you post them as new questions? For the first one, I recommend to look into azimuth() function. I have no idea about the latter one, which would require experts' help.

          – Kazuhito
          Jan 10 at 13:31




















          draft saved

          draft discarded




















































          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%2f308201%2fprojecting-points-on-line-and-calculating-distance-from-line-start%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







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          Npm cannot find a required file even through it is in the searched directory