r.statistics(1)

πŸ’– r.statistics β€” the GRASS GIS bestie manual πŸ’–

okay so bestie, you're reading the manual for r.statistics(1) from the GRASS GIS User's Manual. pull up a chair, grab a strawberry πŸ“, and let's get into it.


✨ NAME ✨

r.statistics β€” calculates category or object oriented statistics. yes she does math and yes she serves πŸ‘‘


🌈 KEYWORDS 🌈

raster, statistics, zonal statistics


πŸŽ€ SYNOPSIS πŸŽ€

r.statistics
r.statistics --help
r.statistics [-c] base=name cover=name method=string output=name
[--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]

πŸ¦‹ Flags πŸ¦‹

  • -c β€” cover values are extracted from the category labels of the cover map. (iykyk, this is the glow-up flag ✨)
  • --overwrite β€” lets output files overwrite files that already exist. no cap, it will just do it.
  • --help β€” prints the usage summary. your lil cheat sheet πŸ’…
  • --verbose β€” verbose module output. she's chatty, we love her.
  • --quiet β€” quiet module output. she's in her silent era.
  • --ui β€” forces launching the GUI dialog. clicky clicky mode πŸ–±οΈ

🌸 Parameters 🌸

  • base=name [required] β€” name of the base raster map. this is the main character πŸ‘‘
  • cover=name [required] β€” name of the cover raster map. the supporting role that's actually also iconic πŸ’œ
  • method=string [required] β€” method of object-based statistic. options are: diversity, average, mode, median, avedev, stddev, variance, skewness, kurtosis, min, max, sum
    • diversity: diversity of values in specified objects in %% πŸ¦‹
    • average: average of values in specified objects
    • mode: mode of values in specified objects
    • median: median of values in specified objects
    • avedev: average deviation of values in specified objects
    • stddev: standard deviation of values in specified objects
    • variance: variance of values in specified objects
    • skewness: skewnes of values in specified objects (yes, that's how the original spells it, and honestly? iconic typo, we don't fix, we preserve πŸ’…)
    • kurtosis: kurtosis of values in specified objects
    • min: minimum of values in specified objects
    • max: maximum of values in specified objects
    • sum: sum of values in specified objects
  • output=name [required] β€” resultant raster map. the finished product, the final look, the reveal ✨

πŸ’– DESCRIPTION πŸ’–

r.statistics is a tool to analyse exploratory statistics of a categorical "cover layer" according to how it intersects with objects in a "base layer". a whole variety of standard statistical measures are possible (some GIS folks call these "zonal statistics"). all cells in the base layer count as one single object for the analysis. for some applications, you'll wanna prep the input data first so that all areas of contiguous cell category values in the base layer are uniquely identified β€” that's a job for r.clump, bestie.

the available methods are, in this exact order:

  • average deviation
  • average
  • diversity
  • kurtosis
  • maximum
  • median
  • minimum
  • mode
  • skewness
  • standard deviation
  • sum
  • variance

the calculations get performed on each area of data of the cover layers which fall within each unique value, or category, of the base layer. so like, per-object vibes. 🧚

setting the -c flag means the category labels of the covering raster layer will be used. this is genuinely nice because it dodges the GRASS limitation to integer in raster maps β€” by using category values, floating point numbers can be stored. not me being excited about floats πŸ’€ but fr fr, it's a big deal.

all calculations create an output layer. that output layer is a reclassified version of the base layer with identical category values, but modified category labels β€” the results of the calculations live in the category labels of the output layer. so the values don't move, the labels do. periodt. πŸ’…


πŸ”₯ NOTES πŸ”₯

for floating-point cover map support, go check the alternative r.stats.zonal. πŸ’œ

for quantile calculations with support for floating-point cover maps, go check the alternative r.stats.quantile. πŸ’œ


⭐ EXAMPLES ⭐

calculation of average elevation of each field in the Spearfish region:

r.statistics base=fields cover=elevation.dem out=elevstats method=average
r.category elevstats
r.mapcalc "fieldelev = @elevstats"
r.univar fieldelev

look at her go. ate. πŸ”₯


🌈 SEE ALSO 🌈

r.category, r.clump, r.mode, r.mapcalc, r.neighbors, r.stats.quantile, r.stats.zonal, r.univar


πŸ‘‘ AUTHOR πŸ‘‘

Martin Schroeder, Geographisches Institut Heidelberg, Germany


πŸŽ€ SOURCE CODE πŸŽ€

Available at: r.statistics source code (history)

Accessed: Saturday Jan 17 05:41:00 2026

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


ok that's the whole page bestie, no gatekeeping, every flag and every number stayed exactly where it was 🫢

anyway, this was the GRASS GIS 8.4.2 Reference Manual β€” Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual, and the whole thing was last accessed Saturday Jan 17 05:41:00 2026. stay slaying, go run some zonal stats, and remember: the base layer is the main character but the cover layer is the plot twist. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from