r.stats.zonal(1grass)
β¨ r.stats.zonal β¨
okay bestie, buckle up, because this is r.stats.zonal from the GRASS User's Manual and it's literally the moment zonal stats became cute π
KEYWORDS: raster, statistics, zonal statistics πΈ
π SYNOPSIS π
r.stats.zonal
r.stats.zonal --help
r.stats.zonal [-cr] base=name cover=name method=string output=name
[--overwrite] [--help] [--verbose] [--quiet] [--ui]
π¦ Flags
-cβ Cover values extracted from the category labels of the cover map-rβ Create reclass map with statistics as category labels--overwriteβ Allow output files to overwrite existing files--helpβ Print usage summary--verboseβ Verbose module output--quietβ Quiet module output--uiβ Force launching GUI dialog
π Parameters
base=name[required] β Name of base raster mapcover=name[required] β Name of cover raster mapmethod=string[required] β Method of object-based statistic
Options: count, sum, min, max, range, average, avedev, variance, stddev, skewness, kurtosis, variance2, stddev2, skewness2, kurtosis2
count: Count of values in specified objectssum: Sum of values in specified objectsmin: Minimum of values in specified objectsmax: Maximum of values in specified objectsrange: Range of values (max - min) in specified objectsaverage: Average of values in specified objectsavedev: Average deviation of values in specified objectsvariance: Variance of values in specified objectsstddev: Standard deviation of values in specified objectsskewness: Skewness of values in specified objectskurtosis: Kurtosis of values in specified objectsvariance2: (2-pass) Variance of values in specified objectsstddev2: (2-pass) Standard deviation of values in specified objectsskewness2: (2-pass) Skewness of values in specified objectskurtosis2: (2-pass) Kurtosis of values in specified objects
output=name[required] β Resultant raster map
π DESCRIPTION π
so r.stats.zonal is the tool that does exploratory statistics on a floating-point "cover layer", and it does it based on how that cover layer intersects with the objects living in a "base layer". you get a whole menu of standard statistical measures to pick from. no cap. π
this kind of analysis is often called zonal statistics β iykyk.
the zones are the base raster map, and the stats get computed from the cells in the cover raster map. and here's the iconic part: the output of this module is spatial πβ¨ The resulting values are recorded as cell values in the output raster map. like, the numbers become the map. main character energy fr fr.
π NOTES π
r.stats.zonal is intended to be a partial replacement for r.statistics β it comes with support for floating-point cover maps, and the trade-off is that it does not support quantiles. if you're here for quantiles, go see r.stats.quantile instead, bestie π«Ά
π EXAMPLE π
In this example, the raster polygon map zipcodes in the North Carolina sample dataset is used to calculate zonal raster statistics using the elevation raster map:
g.region raster=zipcodes -p
# pixel count in zipcode areas
r.stats.zonal base=zipcodes cover=elevation method=count output=zipcodes_elev_count
r.colors zipcodes_elev_count color=gyr -g
# average elevation in zipcode areas
r.stats.zonal base=zipcodes cover=elevation method=average output=zipcodes_elev_avg
r.colors zipcodes_elev_avg color=elevation -g
Figure: ZIP code map on the left shows ZIP code areas, elevation map the respective values per pixel, zonal statistics map on the right shows the average elevation per zone (all maps: spatial subset). π
π SEE ALSO π
r.stats.quantilefor computing quantiles in zones (objects in base raster map),r.quantilefor computing quantiles of a whole raster map,r.statisticsfor categorical (integer) zonal statistics,r.univarfor zonal statistics with textual (non-spatial) output,v.vect.statsfor statistics of vector points in vector areas.
π AUTHOR π
Glynn Clements
π SOURCE CODE π
Available at: r.stats.zonal source code (history)
Latest change: Wednesday May 21 09:11:03 2025 in commit: 45102055f4f205276ad5f85b5775b70c6583a26f
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual
and that's the whole page, periodt π β¨ this was GRASS 8.5.0, mwah, go compute some zones bestie π¦π
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms