r.stats.zonal(1)

✨ r.stats.zonal β€” the manual page, but make it make sense ✨

okay so bestie, you're reading the GRASS GIS User's Manual page for r.stats.zonal(1) πŸ’– This is the one that does category or object oriented statistics β€” aka accumulator-based statistics β€” and honestly? It's giving main character energy. Let's go 🌸


🌈 NAME 🌈

r.stats.zonal β€” calculates category or object oriented statistics (accumulator-based statistics) πŸ’…


πŸŽ€ KEYWORDS πŸŽ€

raster, statistics, zonal statistics β€” yes those three, no cap πŸ¦‹


✨ 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 πŸ‘€ like, it grabs the labels, not the raw numbers, iykyk
  • -r β€” Create reclass map with statistics as category labels πŸŽ€ it makes you a whole reclass map, iconic
  • --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 map πŸ—ΊοΈ
  • cover=name [required] β€” Name of cover raster map 🌸
  • method=string [required] β€” Method of object-based statistic πŸ’…

Options for method: count, sum, min, max, range, average, avedev, variance, stddev, skewness, kurtosis, variance2, stddev2, skewness2, kurtosis2

And here's what each one actually does, spelled out πŸ’–:

  • count: Count of values in specified objects
  • sum: Sum of values in specified objects
  • min: Minimum of values in specified objects
  • max: Maximum of values in specified objects
  • range: Range of values (max - min) in specified objects
  • average: Average of values in specified objects
  • avedev: Average deviation of values in specified objects
  • variance: Variance of values in specified objects
  • stddev: Standard deviation of values in specified objects
  • skewness: Skewness of values in specified objects
  • kurtosis: Kurtosis of values in specified objects
  • variance2: (2-pass) Variance of values in specified objects
  • stddev2: (2-pass) Standard deviation of values in specified objects
  • skewness2: (2-pass) Skewness of values in specified objects
  • kurtosis2: (2-pass) Kurtosis of values in specified objects
  • output=name [required] β€” Resultant raster map 🌈

πŸ’– DESCRIPTION πŸ’–

r.stats.zonal is a tool to analyse exploratory statistics of a floating-point "cover layer" according to how it intersects with objects in a "base layer" πŸ¦‹ A variety of standard statistical measures are possible. This type of analysis is often called zonal statistics. The zones are specified as the base raster map and the statistics are computed from cells in the cover raster map. Notably, the output of this module is spatial: the resulting values are recorded as cell values in the output raster map. Like, the answer itself becomes a map. Ate. πŸ’…


πŸ“ NOTES πŸ“

r.stats.zonal is intended to be a partial replacement for r.statistics β€” it comes with support for floating-point cover maps at the expense of not supporting quantiles 😭 For this, see r.stats.quantile. So like, trade-offs, bestie. You can't have everything (yet). πŸŽ€


🌟 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.quantile for computing quantiles in zones (objects in base raster map) πŸ’œ
  • r.quantile for computing quantiles of a whole raster map 🌈
  • r.statistics for categorical (integer) zonal statistics πŸ“
  • r.univar for zonal statistics with textual (non-spatial) output πŸ’¬
  • v.vect.stats for statistics of vector points in vector areas 🎯

πŸ’« AUTHOR πŸ’«

Glynn Clements 🫢 (thank you for your service, legend)


πŸ”₯ SOURCE CODE πŸ”₯

Available at: r.stats.zonal source code (history)

Accessed: Saturday Jan 17 05:41:00 2026

Main index | Raster index | Topics index | Keywords index | Graphical index | Full index

Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual


and that's the whole page, bestie πŸŽ€ that was GRASS GIS 8.4.2, dated Saturday Jan 17 05:41:00 2026, straight from the GRASS Development Team, Β© 2003-2025 β€” go compute some zones, you absolute icon πŸ‘‘βœ¨πŸ’–

πŸ“¦ where this page comes from