r.li.patchnum(1)

✨ r.li.patchnum ✨

ok bestie so this is a page from the GRASS GIS User's Manual (yes the whole manual, we're just vibing with one lil tool here) and it's all about r.li.patchnum πŸ’–


🌸 NAME 🌸

r.li.patchnum β€” it counts the patch number index on a raster map, and it does it with a 4 neighbour algorithm. that's the whole job. slay. πŸ’…


πŸŽ€ KEYWORDS πŸŽ€

raster, landscape structure analysis, patch index πŸ¦‹


✨ SYNOPSIS ✨

r.li.patchnum
r.li.patchnum --help
r.li.patchnum input=name config=name output=name  [--overwrite]
[--help]  [--verbose]  [--quiet]  [--ui]

🌈 Flags:

  • --overwrite β€” lets your output files just bulldoze over existing files. no cap.
  • --help β€” prints the usage summary, i.e. the "what does this even do" moment
  • --verbose β€” verbose module output, it yaps (affectionate)
  • --quiet β€” quiet module output, it says nothing, main character silence 🀫
  • --ui β€” forces the GUI dialog to launch

πŸ’œ Parameters:

  • input=name [required] β€” the name of the input raster map
  • config=name [required] β€” the configuration file
  • output=name [required] β€” the name you want for the output raster map

πŸ¦‹ DESCRIPTION πŸ¦‹

ok so r.li.patchnum calculates the "patch number index" like this:

f(sample_area)= Patch_Number

and the way it gets there? 4 neighbour algorithm energy. that means when it's tracing a patch, diagonal cells are literally ignored. not invited. blocked. πŸ™ˆ


πŸ’€ NOTES πŸ’€

bestie do NOT use absolute path names for the config and output file/map parameters. i'm so serious. 😭

if you picked the "moving window" method in g.gui.rlisetup, then your output is gonna be a raster map. if you didn't, you get an ASCII file generated in this folder instead:

  • C:\Users\userxy\AppData\Roaming\GRASS8\r.li\output\ (MS-Windows)
  • $HOME/.grass8/r.li/output/ (GNU/Linux)

also!! if the sample area has only NULL values, then it's considered to have zero patches. that's it, that's the rule. ✨


πŸ“ EXAMPLES πŸ“

wanna calculate patch number index on map my_map, using my_conf configuration file (which you already defined earlier with g.gui.rlisetup, obvi) and save the results in my_out? run:

r.li.patchnum input=my_map conf=my_conf out=my_out

Forest map (Spearfish sample dataset) example: 🌲

g.region raster=landcover.30m -p
r.mapcalc "forests = if(landcover.30m >= 41 && landcover.30m <= 43,1,null())"
r.li.patchnum input=forests conf=movwindow7 out=forests_patchnum_mov7
r.univar forests_patchnum_mov7

Forest map (North Carolina sample dataset) example: 🌳

g.region raster=landclass96 -p
r.mapcalc "forests = if(landclass96 == 5, 1, null() )"
r.li.patchnum input=forests conf=movwindow7 out=forests_patchnum_mov7
# verify
r.univar forests_patchnum_mov7
r.to.vect input=forests output=forests type=area
d.mon wx0
d.rast forests_patchnum_mov7
d.vect forests type=boundary

πŸ‘‘ SEE ALSO πŸ‘‘

  • r.li β€” package overview
  • g.gui.rlisetup

πŸ“š REFERENCES πŸ“š

McGarigal, K., and B. J. Marks. 1995. FRAGSTATS: spatial pattern analysis program for quantifying landscape structure. USDA For. Serv. Gen. Tech. Rep. PNW-351. (PDF) 🫢


🧚 AUTHORS 🧚

  • Michael Shapiro - CERL (patch identification)
  • Markus Metz (statistics)

⭐ SOURCE CODE ⭐

Available at: r.li.patchnum source code (history)

Accessed: Saturday Jan 17 05:40:54 2026

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


and that's the whole thing bestie πŸ’– this page is running on GRASS GIS 8.4.2</s> β€” nope wait, it's GRASS 8.4.2, part of the GRASS GIS 8.4.2 Reference Manual, Β© 2003-2025 GRASS Development Team, accessed Saturday Jan 17 05:40:54 2026. ate and left no crumbs. periodt. πŸ’…βœ¨πŸŽ€
πŸ“¦ where this page comes from