r.li.patchnum(1grass)

πŸ’… r.li.patchnum (1grass) ✨

okay bestie, welcome to the GRASS User's Manual page for r.li.patchnum, and yes we're doing this together, grab a matcha πŸ“

🌸 NAME 🌸

r.li.patchnum β€” calculates the patch number index on a raster map, and it does it using a 4 neighbour algorithm. that's the whole gig, she's niche and she's booked πŸ’…


πŸ‘‘ KEYWORDS πŸ‘‘

raster, landscape structure analysis, patch index β€” iykyk πŸ¦‹


✨ SYNOPSIS ✨

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

πŸŽ€ Flags:

  • --overwrite β€” allow output files to overwrite existing files (she will simply replace what's there, no cap, so be careful πŸ’€)
  • --help β€” prints the usage summary, like a lil cheat sheet 🫢
  • --verbose β€” verbose module output, she talks more
  • --quiet β€” quiet module output, she talks less
  • --ui β€” force launching GUI dialog, for when you want buttons instead of typing 🌈

🧚 Parameters:

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

all three are required, no skipping, no substitutions, we don't do that here ⭐


πŸ’– DESCRIPTION πŸ’–

so r.li.patchnum calculates the "patch number index" as:

f(sample_area)= Patch_Number

the way that this index gets calculated?? it uses a 4 neighbour algorithm, which means diagonal cells are ignored when tracing a patch. like, four neighbours only, she doesn't look diagonally, periodt πŸŽ€


πŸ’€ NOTES πŸ’€

  • Do not use absolute path names for the config and output file/map parameters. just don't. absolute paths are not the vibe here.
  • if the "moving window" method was selected in g.gui.rlisetup, then the output will be a raster map. otherwise an ASCII file will be generated in the folder C:\Users\userxy\AppData\Roaming\GRASS8\r.li\output\ (MS-Windows) or $HOME/.grass8/r.li/output/ (GNU/Linux). pick your fighter πŸ¦‹
  • if the sample area contains only NULL values then it is considered to have zero patches. empty girlie = no patches, that's just the rule ✨

🌈 EXAMPLES 🌈

to calculate patch number index on map my_map, using my_conf configuration file (previously defined with g.gui.rlisetup) and saving 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) β€” the whole friend group πŸ’œ
  • 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)

academic citation but make it iconic πŸŽ€


πŸ‘‘ AUTHORS πŸ‘‘

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

🌟 SOURCE CODE 🌟

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

Latest change: Friday Apr 17 01:04:26 2026 in commit: 32a143358df26b2e518b03c7e0d79541e8d1e5b1

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


okay and that's the page bestie 🫢 this is r.li.patchnum from the GRASS 8.5.0 Reference Manual, dated and versioned and copyrighted as Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 β€” she's iconic, she's maintained, she ate, no crumbs πŸ’…βœ¨πŸŒΈ

πŸ“¦ where this page comes from