This vignette uses rasterdiv to build global series of indices of diversity based on Information Theory. The input dataset is the Copernicus Long-term (1999-2017) average Normalised Difference Vegetation Index for the 21st of June (copNDVI).
A RasterLayer called copNDVI is loaded together with the package rasterdiv. copNDVI is a 8-bit raster, meaning that pixel values range from 0 to 255. You could stretch it to match a more familiar (-1,1) values range using raster::stretch(copNDVI,minv=-1,maxv=1)
.
Pixels with values 253, 254 and 255 (water) will be set as NA’s.
To speed up the calculation, the RasterLayer will be “resampled” at a resolution 20 times coarser than original.
rasterdiv allows the computation of 8 diversity indexes based on information theory. In the following section, all these indexes will be computed for copNDVIlr using a moving window of 81 pixels (9 px side). Alpha values for the Hill, Renyi and parametric Rao indexes will be set from 0 to 2 every 0.5. In addition, we will set na.tolerance=0.1
, meaning that all moving windows with more than 10% of pixels equal NA will be set to NA.
#Shannon's Diversity
sha <- Shannon(copNDVIlr,window=9,na.tolerance=0.1,np=1)
#Pielou's Evenness
pie <- Pielou(copNDVIlr,window=9,na.tolerance=0.1,np=1)
#Berger-Parker's Index
ber <- BergerParker(copNDVIlr,window=9,na.tolerance=0.1,np=1)
#Rao's quadratic Entropy
rao <- Rao(copNDVIlr,window=9,na.tolerance=0.1,dist_m="euclidean",shannon=FALSE,np=1)
#Parametric Rao's quadratic entropy with alpha ranging from 1 to 5
prao <- paRao(copNDVIlr,window=9,alpha=1:5,na.tolerance=0.1,dist_m="euclidean",np=1)
#Cumulative Residual Entropy
cre <- CRE(copNDVIlr,window=9,na.tolerance=0.1,np=1)
#Hill's numbers
hil <- Hill(copNDVIlr,window=9,alpha=seq(0,2,0.5),na.tolerance=0.1,np=1)
#Renyi's Index
ren <- Renyi(copNDVIlr,window=9,alpha=seq(0,2,0.5),na.tolerance=0.1,np=1)
#Shannon's Diversity
levelplot(sha,main="Shannon's entropy from Copernicus NDVI 5 km (9 px-side moving window)",as.table = T,layout=c(0,1,1), ylim=c(-60,75), margin = list(draw = TRUE))
#Pielou's Evenness
levelplot(pie,main="Pielou's evenness from Copernicus NDVI 5 km (9 px-side moving window)",as.table = T,layout=c(0,1,1), ylim=c(-60,75), margin = list(draw = TRUE))
#Berger-Parker' Index
levelplot(ber,main="Berger-Parker's index from Copernicus NDVI 5 km (9 px-side moving window)",as.table = T,layout=c(0,1,1), ylim=c(-60,75), margin = list(draw = TRUE))
#Rao's quadratic Entropy
levelplot(rao,main="Rao's quadratic entropy from Copernicus NDVI 5 km (9 px-side moving window)",as.table = T,layout=c(0,1,1), ylim=c(-60,75), margin = list(draw = TRUE))
#Parametric Rao's quadratic Entropy
levelplot(stack(prao),main="Parametric Rao's quadratic entropy from Copernicus NDVI 5 km (9 px-side moving window)",as.table = T,layout=c(0,5,1), ylim=c(-60,75), margin = list(draw = TRUE))
#Cumulative Residual Entropy
levelplot(cre,main="Cumulative Residual Entropy from Copernicus NDVI 5 km (9 px-side moving window)",as.table = T,layout=c(0,1,1), ylim=c(-60,75), margin = list(draw = TRUE))