4

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.

  • Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq. – underdark Mar 11 '16 at 20:35
  • Perhaps this post might help: QGIS calculate distance of point along a line. – Joseph Mar 14 '16 at 12:58
3

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 has distance field.

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).

NB: The $id is unrelated to id field shown in the picture. Sorry if it is confusing.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.