12 Apr 2023

QGIS3: Elevation Gain for LinestringZ Geometry

Use this Expression in the QGIS3 Field Calculator to get the eƶevation gain for a LinestringZ geometry!
array_sum(
	array_filter(
		array_foreach(generate_series(1,num_geometries(nodes_to_points($geometry))),
			z(geometry_n( nodes_to_points($geometry), @element+1))-
			z(geometry_n( nodes_to_points($geometry), @element))
		), @element>0
	)
)