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 mapconfig=name[required] β the configuration fileoutput=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 theconfigandoutputfile/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 overviewg.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
- fedora 44: grass 8.4.2-4.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms