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 map
  • cover=name [required] β€” Name of cover raster map
  • method=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 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 πŸ’…

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.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


πŸ’œ 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