GRASS logo


r.series.diversity - Compute diversity indici over input layers


raster, diversity index, renyi entrophy, shannon, simpson, richness, biodiversity, eveness


r.series.diversity --help
r.series.diversity [-rshpgent] input=name[,name,...] output=name [alpha=number(s)[,number(s),...]] [nprocs=integer] [memory=memory in MB] [--overwrite] [--help] [--verbose] [--quiet] [--ui]


Renyi enthropy index
Richness index
Shannon index
Reversed Simpson index
Gini-Simpson index
Pielou's evenness index
Shannon effective number of species
Total counts
Allow output files to overwrite existing files
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


input=name[,name,...] [required]
input layers
input layers
output=name [required]
prefix name output layer
Order of generalized entropy
Options: 0.0-*
Number of threads for parallel computing
Default: 1
memory=memory in MB
Maximum memory to be used (in MB)
Cache size for raster rows
Default: 300

Table of contents


r.series.diversity computes one or more diversity indices based on 2 or more input layers. Each layer should represents a species (or other categories being used), and its raster values the category count/value. The name of the output layers will consist of the base name provided by the user. Currently implemented are the Renyi entropy index and a number of specialized cases of the Renyi enthropy, viz.the species richness, the Shannon index, the Shannon based effective number of species (ENS), the Simpson index (inverse and gini variants), pielou's eveness (Legendre & Legendre, 1998).

The Renyi enthropy

This index quantify the diversity, uncertainty, or randomness of a system. The user can define the order of diversity by setting the order (alpha) value. The order of a diversity indicates its sensitivity to common and rare species. The diversity of order zero ( alpha = 0) is completely insensitive to species frequencies and is better known as species richness. Increasing the order diminishes the relative weights of rare species in the resulting index (Jost 2006, Legendre & Legendre 1998). The name of the output layer is composed of the basename + renyi + alpha.


The species richness is simply the count of the number of layers. It is a special case of the Reny enthropy: S = exp(R0), whereby S is the species richness R0 the renyi index for alpha=0. The name of the output layer is composed of the basename + richness.

Shannon index

The Shannon (also called the Shannon-Weaver or Shannon-Wiener) index is defined as H' = -sum(p_i x log(p_i)), where p_i is the proportional abundance of species i. The function uses the natural logarithm (one can also use other bases for the log, but that is currently not implemented, and doesn't make a real difference). Note the Shannon index is a special case of the Renyi enthropy for alpha --> 1. The name of the output layer is composed of the basename + shannon.

Effective number of species (ENS)

This option gives the Shannon index, converted to into equivalent or effective numbers of species (also known as Hill numbers) (Lou Jost, 2006; Chase and Knight, 2013). The Shannon index, and other indice, can be converted so they represent the number of equally abundant species necessary to produce the observed value of diversity (an analogue the concept of effective population size in genetics). An advantage of the ENS is a more intuitive behavious, e.g., if two communities with equally abundant but totally distinct species are combined, the ENS of the combined community is twice that of the original communities. See for an explanation and examples this blog post or this one. The name of the output layer is composed of the basename + ens.

Pielou's eveness (equitability) index

Species evenness refers to how close in numbers each species in an environment are. The evenness of a community can be represented by Pielou's evenness index, which is defined as H' / Hmax. H' is the Shannon diversity index and Hmax the maximum value of H', equal to log(species richness). Note that a weakness of this index is its dependence on species counts, and more specifically that it is a ratio of a relatively stable index, H', and one that is strongly dependent on sample size, S. The name of the output layer is composed of the basename + pielou.

Simpson's index of diversity

The Simpson's index is defined as D = sum p_i^2. This is equivalent to -1 * 1 / exp(R2), with R2 the renyi index for alpha=2. With this index, 0 represents infinite diversity and 1, no diversity. As this is counterintuitive behavior for a diversity index, we use 1 - D (Gini, 1912; Simpson, 1949). This is also called the probability of interspecific encounter (PIE) or the Gini–Simpson index. The index represents the probability that two individuals randomly selected from a sample will belong to different species. The value ranges between 0 and 1, with greater values representing greater sample diversity. The name of the output layer is composed of the basename + ginisimpson.

Inverse Simpson index (Simpson's Reciprocal Index)

An alternative way to overcome the problem of the counter-intuitive nature of Simpson's Index is to use the inverse Simpson index, which is defined as ID = 1 / D). The lowest value of this index is 1 and represent a community containing only one species. The higher the value, the greater the diversity. The maximum value is the number of species in the sample. The name of the output layer is composed of the basename + invsimpson.


Note that if you are interested in the landscape diversity, you should have a look at the r.diversity addon or the various related* addons (see below). These functions requires one input layer and compute the diversity using a moving window.

Currently when working with very large raster layers and many input layers, computations can take a long time. Increasing the number of threads (parameter nprocs) and increasing the memory (parameter memory) can speed up the calculations considerably.

See the blog post Tree species diversity distribution for a possible application of this addon.


Suppose we have five layers, each representing number of individuals of a different species. To keep it simple, let's assume individuals of all five species are homogeneous distributed, with respectively 60, 10, 25, 1 and 4 individuals / raster cell densities.
r.mapcalc "spec1 = 60"
r.mapcalc "spec2 = 10"
r.mapcalc "spec3 = 25"
r.mapcalc "spec4 = 1"
r.mapcalc "spec5 = 4"

Now we can calculate the renyi index for alpha is 0, 1 and 2 (this should be 1.61, 1.06 and 0.83 respectively)

r.series.diversity -r in=spec1,spec2,spec3,spec4,spec5 out=renyi alpha=0,1,2 -r map=renyi_Renyi_0_0
max=1.6094379124341 -r map=renyi_Renyi_1_0
max=1.05813420869358 -r map=renyi_Renyi_2_0

You can also compute the species richness, shannon, inverse simpson and gini-simpson indices

r.series.diversity -s -h -p -g in=spec1,spec2,spec3,spec4,spec5 out=biodiversity

The species richness you get should of course be 5. The shannon index is the same as the renyi index with alpha=1 (1.06). The inverse simpson and gini-simpson should be 2.3 and 0.57 respectively. Let's check: -r map=biodiversity_richness
max=5 -r map=biodiversity_shannon
max=1.05813420869358 -r map=biodiversity_invsimpson
max=2.30308613542147 -r map=biodiversity_ginisimpson





Paulo van Breugel,

HAS green academy University of Applied Sciences
Innovative Biomonitoring research group
Climate-robust Landscapes research group


Available at: r.series.diversity source code (history)

Latest change: Wednesday Jul 17 17:40:47 2024 in commit: 35ed82a9db5bd4a6ca0e81da6d5e3b6799fb046b

Main index | Raster index | Topics index | Keywords index | Graphical index | Full index

© 2003-2024 GRASS Development Team, GRASS GIS 8.3.3dev Reference Manual