2

I have got 2 lines in my layer. I would like to measure their distance automatically.

I found the tool, which might be helpful. This is the v.distance algorithm in GRASS, as advised in the link below:

QGIS calculate distance of point along a line

My data attribute table looks like this by far:

enter image description here

and I would like to have the distance for all of them in the Length [meters] column.

I tried the v.distance GRASS plugin, but the situation looks as follows:

enter image description here

I am getting an error:

Wrong or missing parameter value: Column name(s) where values specified by
'upload' option will be uploaded

and I don't really know what to do with it.

I found some similar problem, where the v.distance algorithm also didn't work properly,

GRASS v.distance in QGIS not working

but they suggest changing the code in Python section. Is it still needed?

Is there any way to autocalculate the distance for all line features available in the given layer?

1
  • 1
    What do you mean by "distance"? Length of lines or distance from one line to the other line? Sep 17 '20 at 16:26
4

Am I right in thinking that you want to populate that field with the length of the lines? If so then in the field calculator you would use the expression $length. This is assuming that the layer is in the correct coordinate reference system. If the output has too many decimal places then you can use the expression ROUND($length, x) where x is the number of decimal places you want.

If you want that field to calculate automatically on the fly as you edit the layer, then you need to create a virtual field in the field calculator using the same expression.

1
  • 2
    Also note the difference between $length (ellipsoidal calculations based on the project's ellipsoid and distance unit settings) and length($geometry) (always planimetric in the Spatial Reference System (SRS) of this geometry)
    – MrXsquared
    Sep 17 '20 at 19:52

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.