I have a road network and different points connected to the roads. I would like to measure the distance between several points along the roads.
Basically I want to do the same like the Road Graph Plugin, but I want to measure not only the distance between two points and also would like to get the results in an attribute table.
Best Answer
I first thought this question was basically same as another recent question Points layer distance from the start of line layer in QGIS.
However, there is an added complexity in this one, that OP requires distance between (not a distance from the start point).
So I needed QGIS 3.0
get_feature_by_id()
function to calculate the difference between records.(1) Calculate the distance of each point along the line, from the start point of the line.
Please see Points layer distance from the start of line layer in QGIS
(2) Calculate distance between points, based on the
distance
taken from previous step (1).Again, open the attribute table of
Points
layer, which hasdistance
field.Create a new field
interval
by the below expression:This expression calculates the difference between points by (
value at next row
minusvalue at current row
).NB: The
$id
is unrelated toid
field shown in the picture. Sorry if it is confusing.