r.li.cwed(1grass)

πŸ’– r.li.cwed β€” the GRASS manual page, but make it make sense πŸ’–

okay bestie, gather round, because today we're talking about r.li.cwed(1grass) β€” that's the GRASS module that calculates contrast weighted edge density index on a raster map. yes it's a mouthful, yes the acronym is giving "I made this up at 2am", but it's actually iconic once you get it. πŸ¦‹

KEYWORDS: raster, landscape structure analysis, patch index


✨ SYNOPSIS ✨

like, the whole vibe, verbatim:

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

πŸŽ€ FLAGS πŸŽ€

  • --overwrite β€” lets output files just go ahead and overwrite files that already exist. chaos mode, consented. πŸ’…
  • --help β€” prints the usage summary so you're not out here guessing.
  • --verbose β€” verbose module output. it talks more. we love a chatty module. πŸ—£οΈ
  • --quiet β€” quiet module output. it shuts up. also valid, honestly. 🀫
  • --ui β€” force launches the GUI dialog, for when clicking buttons is the move.

🌸 PARAMETERS 🌸

  • input=name [required] β€” name of the input raster map. the map. the main character.
  • config=name [required] β€” configuration file.
  • path=name [required] β€” name of the file that contains the weight used to calculate the index.
  • output=name [required] β€” name for the output raster map.

no cap: all four of these are required, so don't come to the function empty-handed. πŸ™ˆ


πŸ’œ DESCRIPTION πŸ’œ

so r.li.cwed (contrast weighted edge density) calculates the edge density between patch types you specify. here's the whole thing, and the formula goes a little something like this:

with:

  • k: attribute
  • m: number of non-null attributes in the sampling area
  • eik: total length of edge in landscape between patch types i and k
  • dik: dissimilarity (edge contrast weight) between patch types i and k
  • Area: total landscape area

the input file has one row for each couple of patch types you want to consider in the calculation. every row gets saved using this exact syntax:

patchType1,patchType2,dissimilarityBetweenPatchType1andPatchType2

periodt. that's the format. don't freestyle it. ✨


πŸ“ NOTES πŸ“

do NOT use absolute path names for the config and output file/map parameters. I'm so serious. πŸ’€

if the "moving window" method was selected in g.gui.rlisetup, then the output will be a raster map β€” otherwise an ASCII file gets generated in the folder

C:\Users\userxy\AppData\Roaming\GRASS8\r.li\output\

(that's MS-Windows, bestie) or

$HOME/.grass8/r.li/output/

(that's GNU/Linux πŸ’œ).

also, important one: if the sample area contains only NULL values it's considered to have 0 patch and CWED=0. and if Area is 0, r.li.cwed returns -1. this is only possible if the map is masked.

if you want to change those -1 values to NULL, run this on the resulting map, after index calculation:

r.null setnull=-1 input=my_map

got it? run it subsequently. not before. after. πŸ‘‘


🌈 EXAMPLES 🌈

to calculate the contrast weighted edge density 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.cwed input=my_map conf=my_conf output=my_out \
          path=/path/to/weights.csv

and here's an example for the input "weights.csv" file, so you can see the whole row-of-three-thing in action:

12,16,0.65
44,123,0.32
56,12,0.54
23,66,0.99

see how it's just patch type, patch type, dissimilarity? yeah. slay. πŸ“


πŸ‘€ 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)
  • Markus Metz

πŸ’» SOURCE CODE πŸ’»

available at: r.li.cwed 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


and that's the whole page, bestie!! 🫢 full credit where it's due: Β© 2003-2026 GRASS Development Team, and this is the GRASS 8.5.0 Reference Manual β€” so if you're reading this on some other version, like, vibe check your install first. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from