r.li.patchdensity(1grass)
β¨ r.li.patchdensity β¨
okay bestie, gather round, because this is the r.li.patchdensity manual page from the GRASS User's Manual and it's literally about counting patches for you π
KEYWORDS: raster, landscape structure analysis, patch index πΈ
π SYNOPSIS π
r.li.patchdensity
r.li.patchdensity --help
r.li.patchdensity input=name config=name output=name [--overwrite]
[--help] [--verbose] [--quiet] [--ui]
β¨ Flags β¨
--overwriteβ lets your output files just... overwrite the existing ones. yes queen, bulldoze it π₯--helpβ prints the usage summary, aka the little recap when you're lost π«Ά--verboseβ verbose module output, for when you want the whole tea β--quietβ quiet module output, for when you want silence and vibes only π€«--uiβ forces the GUI dialog to launch. fancy β¨
π Parameters π
input=name[required] β name of the input raster map πconfig=name[required] β the configuration file ποΈoutput=name[required] β the name for the output raster map π
π DESCRIPTION π
so r.li.patchdensity calculates the "patch density index" β which is just the number of patches per square kilometer, no cap. here's the formula bestie:
PD = Npatch / A
with:
- A: the sampling area size
- Npatch: the number of patches
and the way it counts? it uses a 4 neighbour algorithm β so diagonal cells are literally ignored when tracing a patch. periodt π¦
π§ NOTES π§
β οΈ bestie do NOT use absolute path names for theconfigandoutputfile/map parameters. i'm so serious.
if the "moving window" method was selected in g.gui.rlisetup, then your output will be a raster map. otherwise an ASCII file gets generated in one of these folders:
C:\Users\userxy\AppData\Roaming\GRASS8\r.li\output\(MS-Windows)$HOME/.grass8/r.li/output/(GNU/Linux)
also, a sample area that's only NULL values is considered to have zero patches, which means the result is always β₯ 0. iconic, no negatives allowed π
π₯ EXAMPLES π₯
first up: calculating the patch density index on a map called my_map, using the my_conf configuration file (that you already defined earlier with g.gui.rlisetup), and saving the results in my_out:
r.li.patchdensity input=my_map conf=my_conf output=my_out
now the glamorous one β example for Spearfish forest areas:
g.region raster=landcover.30m -p
# extract forested areas:
r.category landcover.30m
r.mapcalc "forests = if(landcover.30m >= 41 && landcover.30m <= 43, 1, null())"
# patch density (7x7 moving window defined in g.gui.rlisetup):
r.li.patchdensity forests conf=movwindow7 out=forests_p_dens7
r.univar forests_p_dens7
d.rast.leg forests_p_dens7
r.to.vect forests out=forests feature=area
d.vect forests type=boundary
and a Forest map (North Carolina sample dataset) example, because we're thorough in this household:
g.region raster=landclass96 -p
r.mapcalc "forests = if(landclass96 == 5, 1, null() )"
r.li.patchdensity input=forests conf=movwindow7 out=forests_patchdensity_mov7
# verify
r.univar forests_patchdensity_mov7
r.to.vect input=forests output=forests type=area
d.mon wx0
d.rast forests_patchdensity_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.patchdensity 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
Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual
anyway that's the whole page bestie, you ate that π«Ά this was r.li.patchdensity(1grass) from GRASS 8.5.0, dropped in the GRASS 8.5.0 Reference Manual, and the last change landed Friday Apr 17 01:04:26 2026 in commit 32a143358df26b2e518b03c7e0d79541e8d1e5b1. go calculate some patch density, mwah πβ¨
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· 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