2

I have a shapefile with a MultiLineStringZ geometry type that I created using the grass v.drape function to attach z-values from a DEM. In order to calculate the 3d length of a line segment, can I use the $length function in the QGIS field calculator, or will this function only report the 2D length?

2
  • 3
    A simple test with two identical features but with wildly different Z values at the points gives the same $length value. Maybe submit a documentation issue to make this explicit in the help if it is the case? Also, I can't find a function or plugin that says it can measure 3d line lengths for things with Z geometry.
    – Spacedman
    Commented Feb 23, 2021 at 18:30
  • 1
    @Spacedman you are right, I did this simple test over a volcano (one 2d one 3d) and they yielded the same length when length was calculated via $length function in the field calculator. I'll submit a documentation issue to try and clarify this.
    – jamierob
    Commented Feb 23, 2021 at 22:41

2 Answers 2

6

For QGIS versions QGIS 3.20 and greater

Now one can calculate the 3D length of a MultiLineStringZ with the length3D($geometry) function, see the Changelog for QGIS 3.20 for more details.

3

For QGIS versions lower than QGIS 3.20

No, the $length function only reports lengths from 2d geometries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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