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.
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.
(2) Calculate distance between points, based on the
distance taken from previous step (1).
Again, open the attribute table of
Points layer, which has
Create a new field
interval by the below expression:
attribute(get_feature_by_id('Points', $id+1), 'distance') - attribute(get_feature_by_id('Points', $id), 'distance')
This expression calculates the difference between points by (
value at next row minus
value at current row).
$id is unrelated to
id field shown in the picture. Sorry if it is confusing.