Aggregating a continuous raster to zones — Recipe (QGIS)

Tool-bound implementation of the Aggregating a continuous raster to zones (Task) Task Schema in QGIS 4.2. Worked example: Soil carbon and land use at Ledreborg (Example).

Data you need

RoleFormLevel of measurementNotes
Continuous rasterraster, one band of valuesinterval or ratioe.g. soil organic carbon, elevation, a vegetation index; know its unit, depth or date and how it was made
Zonespolygonsnominal zone typee.g. landscapes
Categorical raster (optional)raster on the same gridnominal classesto summarise the surface per class, e.g. per land use
Statistics (output)the zones with statistics fieldsratiocount, mean, median, …

Statistics per zone type (Task Schema steps 3–4)

  1. If several polygons share a type, Dissolve (Tool - QGIS) the zones by the type field, so types are combined from cells, not from polygon means.
  2. Zonal statistics (Tool - QGIS): Raster layer the surface, Statistics to calculate Count, Mean, Median (add Max to spot extremes).

Statistics per class (step 5)

Zonal statistics by class (Tool - QGIS) (SemanticGIS plugin): Categorical raster the classes, styled with their legend or with a .qml file, and Value raster the surface. The output table has one row per legend label, with count, area, mean, median, quartiles and standard deviation. The two rasters may differ in cell size and CRS.

Without the plugin: Raster layer zonal statistics (Raster analysis), with Input layer the surface and Zones layer the categorical raster. Both rasters need the same cell size and alignment. The output table has one row per class code, without names, with count, sum, minimum, maximum and mean.

To restrict either result to the zones, first Clip raster by mask layer the surface with the zones.

Checked in QGIS 4.2.2, October 2026.