Zonal statistics by class — Tool (QGIS)

In QGIS: Processing Toolbox › SemanticGIS › Raster analysis › Zonal statistics by class (legend labels) (semanticgis:zonalstatisticslegend, SemanticGIS plugin 0.7.16 and later).

Realises:

Settings that matter

  • Categorical raster (zones): land use, for example. Labels come from its Paletted/Unique values style, or from a .qml file.
  • Value raster: the surface to summarise, such as NDVI or elevation.
  • One row per legend label: values that share a label are pooled into one row, and their raster values are listed in class_values. Untick it to get one row per raster value.
  • Count on: the value raster’s grid (the default, each value counted once) or the categorical raster’s grid. The other raster is resampled by nearest neighbour, so the two may differ in pixel size and CRS.
  • The output is a table with label, count, area (map units², m² in a UTM CRS), sum, mean, median, stddev, min, max, range, q1, q3 and iqr. The names are the same as in Statistics by categories.

Watch out

  • QGIS’s own Raster layer zonal statistics gives one row per raster value, with no names and no median or quartiles, and needs both rasters on the same grid.
  • Values the legend does not name get the label value <n>, and the log lists them.
  • The tool holds all the values in memory. Clip large rasters to the study area first.

Checked in QGIS 4.2.2, November 2026. Names and options can differ in other versions.