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 map
  • config=name [required] โ€” configuration file
  • output=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 type i โญ

that's it, that's the formula, and she ate ๐Ÿ’…


๐Ÿ™ˆ NOTES ๐Ÿ™ˆ

do NOT use absolute path names for the config and output file/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