Skip to main content
added 202 characters in body
Source Link
Bera
  • 77.7k
  • 14
  • 78
  • 187

You can use a virtual layer and join each point to a line (I use within 5 m distance below) and measure the distance along the line. ST_Line_Locate_Point:

return a number (between 0.0 and 1.0) representing the location of the closest point on LineString to the given Point, as a fraction of total 2d line length

so I multiply with the line length:. Replace "waypoint" with the name of your point layer and "path" with the name of your line layer. And add more fields from the point layer if you want to. Like select pnt.id, pnt.someotherfield, ...

select  pnt.id, pnt.geometry, 
        round(ST_Line_Locate_Point(line.geometry, pnt.geometry)*st_length(line.geometry),1) as distalongline
from "waypoint" pnt
left join "path" line
on PtDistWithin(pnt.geometry, line.geometry, 5)
order by ST_Line_Locate_Point(line.geometry, pnt.geometry)

enter image description here

You can use a virtual layer and join each point to a line (I use within 5 m distance below) and measure the distance along the line. ST_Line_Locate_Point:

return a number (between 0.0 and 1.0) representing the location of the closest point on LineString to the given Point, as a fraction of total 2d line length

so I multiply with the line length:

select  pnt.id, pnt.geometry, 
        round(ST_Line_Locate_Point(line.geometry, pnt.geometry)*st_length(line.geometry),1) as distalongline
from "waypoint" pnt
left join "path" line
on PtDistWithin(pnt.geometry, line.geometry, 5)
order by ST_Line_Locate_Point(line.geometry, pnt.geometry)

enter image description here

You can use a virtual layer and join each point to a line (I use within 5 m distance below) and measure the distance along the line. ST_Line_Locate_Point:

return a number (between 0.0 and 1.0) representing the location of the closest point on LineString to the given Point, as a fraction of total 2d line length

so I multiply with the line length. Replace "waypoint" with the name of your point layer and "path" with the name of your line layer. And add more fields from the point layer if you want to. Like select pnt.id, pnt.someotherfield, ...

select  pnt.id, pnt.geometry, 
        round(ST_Line_Locate_Point(line.geometry, pnt.geometry)*st_length(line.geometry),1) as distalongline
from "waypoint" pnt
left join "path" line
on PtDistWithin(pnt.geometry, line.geometry, 5)
order by ST_Line_Locate_Point(line.geometry, pnt.geometry)

enter image description here

Source Link
Bera
  • 77.7k
  • 14
  • 78
  • 187

You can use a virtual layer and join each point to a line (I use within 5 m distance below) and measure the distance along the line. ST_Line_Locate_Point:

return a number (between 0.0 and 1.0) representing the location of the closest point on LineString to the given Point, as a fraction of total 2d line length

so I multiply with the line length:

select  pnt.id, pnt.geometry, 
        round(ST_Line_Locate_Point(line.geometry, pnt.geometry)*st_length(line.geometry),1) as distalongline
from "waypoint" pnt
left join "path" line
on PtDistWithin(pnt.geometry, line.geometry, 5)
order by ST_Line_Locate_Point(line.geometry, pnt.geometry)

enter image description here