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?

  • 1
    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
    Feb 23, 2021 at 18:30
  • @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
    Feb 23, 2021 at 22:41

1 Answer 1


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.