I am trying to measure the distance of each bus stop along a number of different bus routes. The data source is OSM routes and stops, subsequently saved as shapefiles within QGIS. CRS is EPSG:27700 - OSGB36 / British National Grid so I can measure in metres.
Based on the answer to (Points layer distance from the start of line layer in QGIS), I have been using a calculated field with the following formula: line_locate_point(geometry:=geometry(get_feature('[RouteLayer]','[RouteID]',"[RouteID]")),point:=$geometry)
...and this seemed to work OK. However upon closer inspection I have spotted that some distances are out of sequence (i.e. the 6th point measured as being further along the route at 2375m than the 7th at 2108m) This happens at further points along the line too...the points highlighted in the image for one particular route stand out as obvious errors. I've checked the validity of the route layer and this returns no errors.
Can anyone suggest what else I can try to understand the cause of the problem and how I might resolve it?
Ultimately I'll be doing this analysis on hundreds of bus routes so manually checking/correcting each one will not be feasible.
EDIT: I've determined the problem is caused by the direction of line digitisation being inconsistent along my route.
My route is a multiline string so I used the Vector/Geometry Tools/Multipart to Single Parts tool to divide the route up into it's individual segments. Then I added a direction marker to each segment. This showed that the segments do not all "flow" in the same direction...so I suspect that if a stop point coincided with a "reversed" segment then the measurement was taken from the wrong end of the segment. Which is why some distance points were in the wrong order. Where there were lots of small segments, the problem was masked, but where a stop occurred on a longer segment, the error was more obvious.
...now to work out how to make everything flow in the same direction!