r.mode(1)

πŸ¦‹ r.mode(1) β€” GRASS GIS User's Manual πŸ¦‹

okay bestie, gather round, because r.mode is literally the friend who takes a whole crowd's vibe and picks the most popular one πŸ’… this is page r.mode(1) from the GRASS GIS User's Manual and it's lowkey iconic.


✨ NAME ✨

r.mode β€” finds the mode of values in a cover map within areas assigned the same category value in a user-specified base map. fr fr that's the whole personality πŸŽ€


🏷️ KEYWORDS 🏷️

raster, statistics, algebra


🫢 SYNOPSIS 🫢

r.mode
r.mode --help
r.mode base=string cover=string output=string  [--overwrite]  [--help]
[--verbose]  [--quiet]  [--ui]

🚩 Flags 🚩

  • --overwrite β€” Allow output files to overwrite existing files (yes queen, permission to replace, use wisely 😭)
  • --help β€” Print usage summary
  • --verbose β€” Verbose module output
  • --quiet β€” Quiet module output
  • --ui β€” Force launching GUI dialog

🌸 Parameters 🌸

  • base=string [required] β€” Base map to be reclassified
  • cover=string [required] β€” Coverage map
  • output=string [required] β€” Output map

πŸ’– DESCRIPTION πŸ’–

so what does it DO. r.mode calculates the most frequently occurring value (i. e., mode) of data contained in a cover raster map layer for areas assigned the same category value in the user-specified base raster map layer. All those modes get stored in the new output map layer. it's giving "everyone pick your fave, we're tallying" ✨

The output map is actually a reclass of the base map. not me making a whole new map that's secretly the old map in a costume 🎭

The base parameter defines an existing raster map layer in the user's current mapset search path. For each group of cells assigned the same category value in the base map, the mode of the values assigned these cells in the cover map will be computed. so like, every little clique in the base map gets its own most-popular cover value πŸ’…

The cover parameter defines an existing raster map layer containing the values to be used to compute the mode within each category of the base map. that's the data getting voted on bestie πŸ—³οΈ


⚠️ NOTES ⚠️

The user should use the results of r.mode with care. Since this utility assigns a value to each cell which is based on global information (i.e., information at spatial locations other than just the location of the cell itself), the resultant map layer is only valid if the geographic region and mask settings are the same as they were at the time that the result map was created. 🚨

ngl that's the big one β€” this map remembers the era it was born in. change your region or your mask and it's no longer telling the truth, periodt.

Results are affected by the current region settings and mask. no cap. 🌈


🌟 EXAMPLE 🌟

Mode of K-factor (erosion) for Spearfish fields:

g.region raster=fields -p
r.mode base=fields cover=soils.Kfactor output=K.by.farm.mode
r.univar K.by.farm.mode

look at her go 😭 set the region, run the mode, then check your work. chef's kiss 🧚


πŸ‘€ SEE ALSO πŸ‘€

g.region, r.category, r.clump, r.describe, r.mapcalc, r.mfilter, r.neighbors, r.reclass, r.stats, r.statistics, r.univar

the whole squad, honestly 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Michael Shapiro, U.S.Army Construction Engineering Research Laboratory


πŸ’» SOURCE CODE πŸ’»

Available at: r.mode source code (history)

Accessed: Saturday Jan 17 05:40:50 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 tea, bestie πŸ“ β€” this page is from GRASS GIS 8.4.2, the reference manual date stamped Saturday Jan 17 05:40:50 2026, so go forth and find your mode πŸ’œβœ¨

πŸ“¦ where this page comes from