{"id":992,"date":"2026-04-10T17:56:53","date_gmt":"2026-04-10T15:56:53","guid":{"rendered":"https:\/\/sigeo.cerege.fr\/?p=992"},"modified":"2026-04-10T17:56:53","modified_gmt":"2026-04-10T15:56:53","slug":"project-points-onto-line-using-qgis","status":"publish","type":"post","link":"https:\/\/sigeo.cerege.fr\/?p=992","title":{"rendered":"Project points onto line using Qgis"},"content":{"rendered":"\n<p>Method to project points onto a line and calculate a curvilinear distance along the line. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Projection<\/h2>\n\n\n\n<p>First project the points using <strong>&#8220;Snap geometries to layer&#8221;<\/strong> tool (&#8220;Accrocher les g\u00e9om\u00e9tries \u00e0 la couche&#8221;). Set the tolerance distance and choose the second behavior &#8220;Privil\u00e9gie le point le plus proche, ajoute des sommets lorsque n\u00e9cessaire&#8221;. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"707\" src=\"https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-1024x707.png\" alt=\"\" class=\"wp-image-993\" srcset=\"https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-1024x707.png 1024w, https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-300x207.png 300w, https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-768x530.png 768w, https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-1536x1060.png 1536w, https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-2048x1413.png 2048w, https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-1200x828.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p>Or use this Python code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>processing.run(\"native:snapgeometries\", {'INPUT':'D:\\tmp\\project_along_line\\points.shp','REFERENCE_LAYER':'D:\\tmp\\project_along_line\\line.shp','TOLERANCE':12000,'BEHAVIOR':1,'OUTPUT':'TEMPORARY_OUTPUT'})<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Curvilinear distance calculation<\/h2>\n\n\n\n<p>Next, in the field calculator of the projected point layer, calculate a new field with this expression : <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>line_locate_point(overlay_nearest('line',$geometry)&#91;0],$geometry)<\/code><\/pre>\n\n\n\n<p>Replace &#8216;line&#8217; by the name of your line layer<\/p>\n\n\n\n<p>or this expression should also work : <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>line_locate_point(<br>geometry( overlay_nearest('ma_ligne', $currentfeature)&#91;0] ),<br>closest_point(<br>geometry( overlay_nearest('ma_ligne', $currentfeature)&#91;0] ),<br>$geometry<br>)<br>)<\/code><\/pre>\n\n\n\n<p>And that&#8217;s it!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"606\" src=\"https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-1-1024x606.png\" alt=\"\" class=\"wp-image-994\" srcset=\"https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-1-1024x606.png 1024w, https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-1-300x178.png 300w, https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-1-768x455.png 768w, https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-1-1536x909.png 1536w, https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-1-2048x1213.png 2048w, https:\/\/sigeo.cerege.fr\/wp-content\/uploads\/2026\/04\/image-1-1200x711.png 1200w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Method to project points onto a line and calculate a curvilinear distance along the line. Projection First project the points using &#8220;Snap geometries to layer&#8221; tool (&#8220;Accrocher les g\u00e9om\u00e9tries \u00e0 la couche&#8221;). Set the tolerance distance and choose the second behavior &#8220;Privil\u00e9gie le point le plus proche, ajoute des sommets lorsque n\u00e9cessaire&#8221;. Or use this &hellip; <a href=\"https:\/\/sigeo.cerege.fr\/?p=992\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project points onto line using Qgis&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-992","post","type-post","status-publish","format-standard","hentry","category-sigeo"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/sigeo.cerege.fr\/index.php?rest_route=\/wp\/v2\/posts\/992","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sigeo.cerege.fr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sigeo.cerege.fr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sigeo.cerege.fr\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sigeo.cerege.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=992"}],"version-history":[{"count":1,"href":"https:\/\/sigeo.cerege.fr\/index.php?rest_route=\/wp\/v2\/posts\/992\/revisions"}],"predecessor-version":[{"id":995,"href":"https:\/\/sigeo.cerege.fr\/index.php?rest_route=\/wp\/v2\/posts\/992\/revisions\/995"}],"wp:attachment":[{"href":"https:\/\/sigeo.cerege.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sigeo.cerege.fr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sigeo.cerege.fr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}