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!
			z(geometry_n( nodes_to_points($geometry), @element+1))-
			z(geometry_n( nodes_to_points($geometry), @element))
		), @element>0

9 Mar 2023

QGIS3: Neat trick to convert color name into color rgb string

color_mix_rgb('blue', 'white', 0)
Arguments to the function are color1: a color string, color2: a color string, ratio: the ratio at which the two colors will be mixed. The output is:
The usecase is converting a color name, stored in a field (field name is "color_name_code"), to a color string to be used for symbolizing layer features, like so:
color_mix_rgb("color_name_code", 'white', 0.2)
which will give me a bit of a pastel tone, by mixing white into the given "color_name_code" (blue, red, green, etc.) with a ratio of 0.2

27 Feb 2023

QGIS3: Find Minimum/Maximum/Mean Raster Value (Elevation) for Polygon Overlay

For finding raster value statistics (Min, Max, Mean) for a polygon overlay, I apply this expression in a virtual field by using the field calculator. The raster layer that I'm querying is named
The functions is looking for the min. raster value at the polygon's nodes

		generate_series(1, num_points($geometry), 1),
		raster_value('DGM_merged', 1, 
			point_n(nodes_to_points($geometry), @element)