QGIS – How to Calculate the 3D Length of Line Segment in QGIS

grassqgisqgis-processing

I've been looking through all of the GRASS commands in the QGIS 2.10 processing toolbox and it seems like one of these must be able to do this but I haven't found one yet. There is 'v.sample' which can sample a DEM at a point location. Is there a way to do something similar to sample a DEM when calculating the length of a line segment?

Best Answer

You can also calculate the length of a line taking into account the topography the following way:

Use the "Profiles from line" (SAGA) tool, which adds points along the line, giving the length from the line start to each point ("DIST" as the length on a flat surface, "DIST_SURF" with heights included).

Select the point with the maximum length value with "extract by expression". If you have multiple lines, use this expression: "DIST_SURF" = maximum("DIST_SURF","LINE_ID"), which will extract the max. point for each line.

Then join these values back to the original line layer, taking only "DIST_SURF" from the point layer.

Admittedly it's not in GRASS but it still works.

Related Question