Projecting points on line and calculating distance from line start












1














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









New contributor




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

























    1














    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









    New contributor




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























      1












      1








      1







      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









      New contributor




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











      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









      New contributor




      stamatis 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




      stamatis 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








      edited 49 mins ago









      Taras

      2,0172623




      2,0172623






      New contributor




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









      asked 2 hours ago









      stamatisstamatis

      113




      113




      New contributor




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





      New contributor





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






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






















          1 Answer
          1






          active

          oldest

          votes


















          3














          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 ?
            – stamatis
            1 hour ago










          • 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
            1 hour ago










          • Question edited. Looking forward for the answer :)
            – stamatis
            53 mins ago










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










          • @Kazuhito, does it play any role which CRS is applied or which CRS the layers are saved in?
            – Taras
            40 mins ago











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


          }
          });






          stamatis 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%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









          3














          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 ?
            – stamatis
            1 hour ago










          • 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
            1 hour ago










          • Question edited. Looking forward for the answer :)
            – stamatis
            53 mins ago










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










          • @Kazuhito, does it play any role which CRS is applied or which CRS the layers are saved in?
            – Taras
            40 mins ago
















          3














          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 ?
            – stamatis
            1 hour ago










          • 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
            1 hour ago










          • Question edited. Looking forward for the answer :)
            – stamatis
            53 mins ago










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










          • @Kazuhito, does it play any role which CRS is applied or which CRS the layers are saved in?
            – Taras
            40 mins ago














          3












          3








          3






          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 27 mins ago

























          answered 2 hours ago









          KazuhitoKazuhito

          14.4k31576




          14.4k31576












          • Is there a way to obtain the projection distance from the line ?
            – stamatis
            1 hour ago










          • 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
            1 hour ago










          • Question edited. Looking forward for the answer :)
            – stamatis
            53 mins ago










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










          • @Kazuhito, does it play any role which CRS is applied or which CRS the layers are saved in?
            – Taras
            40 mins ago


















          • Is there a way to obtain the projection distance from the line ?
            – stamatis
            1 hour ago










          • 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
            1 hour ago










          • Question edited. Looking forward for the answer :)
            – stamatis
            53 mins ago










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










          • @Kazuhito, does it play any role which CRS is applied or which CRS the layers are saved in?
            – Taras
            40 mins ago
















          Is there a way to obtain the projection distance from the line ?
          – stamatis
          1 hour ago




          Is there a way to obtain the projection distance from the line ?
          – stamatis
          1 hour ago












          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
          1 hour ago




          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
          1 hour ago












          Question edited. Looking forward for the answer :)
          – stamatis
          53 mins ago




          Question edited. Looking forward for the answer :)
          – stamatis
          53 mins ago












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




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












          @Kazuhito, does it play any role which CRS is applied or which CRS the layers are saved in?
          – Taras
          40 mins ago




          @Kazuhito, does it play any role which CRS is applied or which CRS the layers are saved in?
          – Taras
          40 mins ago










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










          draft saved

          draft discarded


















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













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












          stamatis 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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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

          Hivernacle

          Fluorita

          Hulsita