r.li.shannon(1grass)
๐ r.li.shannon โ the Shannon's diversity index girlie ๐
okay so bestie, welcome to r.li.shannon, a GRASS User's Manual classic โจ it calculates Shannon's diversity index on a raster map. that's the whole vibe. landscape structure analysis, diversity index energy, no cap ๐ฆ
โจ KEYWORDS โจ
raster, landscape structure analysis, diversity index ๐
๐ธ SYNOPSIS ๐ธ
r.li.shannon
r.li.shannon --help
r.li.shannon input=name config=name output=name [--overwrite] [--help]
[--verbose] [--quiet] [--ui]
๐ Flags:
--overwriteโ let your output files just bulldoze over existing files, periodt. allow output files to overwrite existing files ๐--helpโ prints the usage summary, iykyk--verboseโ verbose module output, so it tells you everything ๐--quietโ quiet module output, shhh ๐คซ--uiโ forces the GUI dialog to launch, main character energy
๐ฆ Parameters:
input=name[required] โ name of input raster mapconfig=name[required] โ configuration fileoutput=name[required] โ name for output raster map
๐ DESCRIPTION ๐
so r.li.shannon calculates the "Shannon's diversity index" as:
and the pieces are:
iโ patch type ๐mโ number of different patch types ๐piโ proportional abundance of patch typeiโญ
that's it, that's the formula, and she ate ๐
๐ NOTES ๐
do NOT use absolute path names for theconfigandoutputfile/map parameters. literally don't. bestie I'm begging ๐ซถ
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 the folder:
C:\Users\userxy\AppData\Roaming\GRASS8\r.li\output\(MS-Windows)$HOME/.grass8/r.li/output/(GNU/Linux)
and one more thing: if the input raster map contains only NULL values then r.li.shannon returns NULL. it's giving nothing, because there is nothing ๐ญ
๐ EXAMPLES ๐
wanna calculate Shannon's diversity index on map my_map, using the my_conf configuration file (previously defined with g.gui.rlisetup) and saving the results in my_out? say less:
r.li.shannon input=my_map conf=my_conf output=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.shannon input=forests conf=movwindow7 out=forests_shannon_mov7
r.univar forests_shannon_mov7
Forest map (North Carolina sample dataset) example: ๐ณ
g.region raster=landclass96 -p
r.mapcalc "forests = if(landclass96 == 5, 1, null() )"
r.li.shannon input=forests conf=movwindow7 out=forests_shannon_mov7
# verify
r.univar forests_shannon_mov7
r.to.vect input=forests output=forests type=area
d.mon wx0
d.rast forests_shannon_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 ๐
Serena Pallecchi, student of Computer Science University of Pisa (Italy). ๐
Commission from Faunalia Pontedera (PI), Italy (www.faunalia.it) ๐ฎ๐น
๐ฅ SOURCE CODE ๐ฅ
Available at: r.li.shannon 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 pookie we're at the very end ๐ฅน this whole thing is GRASS 8.5.0 and it's the r.li.shannon(1grass) page, ยฉ 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual. slay, go run it, and hydrate ๐ง๐๐
๐ฆ 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