Zonal statistics
Summary statistics of raster cell values inside each zone polygon.
Pitfall. Zones smaller than a cell may get no cells at all unless all_touched is set.
Pitfall. Overlapping zones are handled differently by different engines; some rasterize them and lose the overlap.
| Also called | Zonal Statistics as Table, zonal stats, summarize raster within polygons |
|---|---|
| Group | raster/statistics |
| Checks | crs.agreement, raster.nodata, raster.stats_sampled |
| Pitfalls | 2 listed above |
| Columbus tool | raster_op · zonal_stats |
| Notes | Not stated |
| Status | active |
| Broader | Not stated |
| Narrower | Not stated |
| Related | Not stated |
Parameters
| Name | Type | Required | Default | Values | Note |
|---|---|---|---|---|---|
stats | list | no | Not stated | count, mean, min, max, sum, std | Not stated |
band | integer | no | Not stated | Not stated | Not stated |
all_touched | boolean | no | Not stated | Not stated | Count every cell a zone touches, not only cells whose centre is inside. |
Inputs and outputs
| Direction | Name | Type | Geometry | Note |
|---|---|---|---|---|
| Input | raster | raster | Not stated | Not stated |
| Input | zones | vector | polygon | Not stated |
| Output | output | vector | Not stated | Not stated |
In each engine
| Engine | Tool | Parameters | Differences |
|---|---|---|---|
gdal | gdal raster zonal-stats |
|
|
grass | v.rast.stats |
|
Preset: {"column_prefix":"zonal"} |
qgis | native:zonalstatisticsfb |
|
|
rasterstats | rasterstats.gen_zonal_stats |
|
|
terra | terra::zonal |
|
|
whiteboxtools | ZonalStatistics |
|
|
xarray-spatial | xrspatial.zonal_stats |
|
|