r.diversity
Calculate diversity indices based on a moving window using r.li packages
r.diversity [-t] input=name prefix=name [alpha=alpha value for Renyi entropy [,alpha value for Renyi entropy,...]] [size=moving window [,moving window,...]] [method=method [,method,...]] [exclude=exclude method [,exclude method,...]] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]
Example:
r.diversity input=name prefix=name
grass.script.run_command("r.diversity", input, prefix, alpha=None, size=3, method="simpson,shannon,pielou,renyi", exclude=None, flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)
Example:
gs.run_command("r.diversity", input="name", prefix="name")
grass.tools.Tools.r_diversity(input, prefix, alpha=None, size=3, method="simpson,shannon,pielou,renyi", exclude=None, flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)
Example:
tools = Tools()
tools.r_diversity(input="name", prefix="name")
This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.
Parameters
input=name [required]
Name of input raster map
prefix=name [required]
Prefix for output raster map(s)
alpha=alpha value for Renyi entropy [,alpha value for Renyi entropy,...]
Order of generalized entropy (> 0.0; undefined for 1.0)
size=moving window [,moving window,...]
Size of processing window (odd number only)
Default: 3
method=method [,method,...]
Name of methods to use
Allowed values: simpson, shannon, pielou, renyi
Default: simpson,shannon,pielou,renyi
exclude=exclude method [,exclude method,...]
Exclude methods
Allowed values: simpson, shannon, pielou, renyi
-t
Preserve configuration files
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--qq
Very quiet module output
--ui
Force launching GUI dialog
input : str, required
Name of input raster map
Used as: input, raster, name
prefix : str, required
Prefix for output raster map(s)
Used as: output, raster, name
alpha : float | list[float] | str, optional
Order of generalized entropy (> 0.0; undefined for 1.0)
Used as: alpha value for Renyi entropy
size : int | list[int] | str, optional
Size of processing window (odd number only)
Used as: moving window
Default: 3
method : str | list[str], optional
Name of methods to use
Used as: method
Allowed values: simpson, shannon, pielou, renyi
Default: simpson,shannon,pielou,renyi
exclude : str | list[str], optional
Exclude methods
Used as: exclude method
Allowed values: simpson, shannon, pielou, renyi
flags : str, optional
Allowed values: t
t
Preserve configuration files
overwrite : bool, optional
Allow output files to overwrite existing files
Default: None
verbose : bool, optional
Verbose module output
Default: None
quiet : bool, optional
Quiet module output
Default: None
superquiet : bool, optional
Very quiet module output
Default: None
input : str | np.ndarray, required
Name of input raster map
Used as: input, raster, name
prefix : str | type(np.ndarray) | type(np.array) | type(gs.array.array), required
Prefix for output raster map(s)
Used as: output, raster, name
alpha : float | list[float] | str, optional
Order of generalized entropy (> 0.0; undefined for 1.0)
Used as: alpha value for Renyi entropy
size : int | list[int] | str, optional
Size of processing window (odd number only)
Used as: moving window
Default: 3
method : str | list[str], optional
Name of methods to use
Used as: method
Allowed values: simpson, shannon, pielou, renyi
Default: simpson,shannon,pielou,renyi
exclude : str | list[str], optional
Exclude methods
Used as: exclude method
Allowed values: simpson, shannon, pielou, renyi
flags : str, optional
Allowed values: t
t
Preserve configuration files
overwrite : bool, optional
Allow output files to overwrite existing files
Default: None
verbose : bool, optional
Verbose module output
Default: None
quiet : bool, optional
Quiet module output
Default: None
superquiet : bool, optional
Very quiet module output
Default: None
Returns:
result : grass.tools.support.ToolResult | np.ndarray | tuple[np.ndarray] | None
If the tool produces text as standard output, a ToolResult object will be returned. Otherwise, None
will be returned. If an array type (e.g., np.ndarray) is used for one of the raster outputs, the result will be an array and will have the shape corresponding to the computational region. If an array type is used for more than one raster output, the result will be a tuple of arrays.
DESCRIPTION
r.diversity calculates selected diversity indices by calling various r.li commands.
This script uses the Pielou, Renyi, Shannon and Simpson indices. The output is a map for each index.
NOTES
The user does not need to create a "conf" file with r.li.setup because
this file will be created automatically by the script.
In size option it is possible use more values: the user can set more
values with comma (,) and a range with minus (-).
If you calculate Renyi entropy remember to add the alpha option.
Alpha option support single and multi values but not a range.
If the input raster contains NULL value cells, r.diversity returns -1
for these cells.
If the user wants to keep NULL values instead, run subsequently on the
resulting map:
r.null map=my_map setnull=-1
EXAMPLES
To calculate the set of indices from a NDVI map, with a moving window of 3 x 3 pixel, run:
r.diversity input=ndvi_map prefix=diversity alpha=0.5
To calculate the set of indices from a NDVI map, with a moving window of 7 x 7 pixel, run:
r.diversity input=ndvi_map prefix=diversity alpha=0.5 size=7
To calculate only Pielou and Simpson indices from a NDVI map, with several moving window (3 x 3, 5 x 5, 7 x 7, 9 x 9), run:
r.diversity input=ndvi_map prefix=diversity size=3-9 method=pielou,simpson
To calculate all methods excluding Pielou from a NDVI map, with two moving window (3 x 3, 9 x 9), run:
r.diversity input=ndvi_map prefix=diversity size=3,9 exclude=pielou alpha=3
SEE ALSO
r.li, r.li.pielou, r.li.renyi, r.li.shannon, r.li.simpson
AUTHORS
Luca Delucchi and Duccio Rocchini, Fondazione E. Mach (Italy)
SOURCE CODE
Available at: r.diversity source code
(history)
Latest change: Thursday Feb 20 13:02:26 2025 in commit 53de819