This vignette shows how to use rasterdiv to calculate Rao’s Index for multiple numerical matrices.
We will create two RasterLayers representing environmental conditions with some non-random spatial patterns. we fist create a grid.
The spatial autocorrelated pattern will be obtained using a semivariogram model with defined sill (value that the semivariogram attains at the range) and range (distance of 0 spatial correlation) and then predicting the semivariogram model over the lattice grid using unconditional Gaussian simulation.
varioMod <- vgm(psill=0.005, range=100, model='Exp') # psill=partial sill=(sill-nugget) # Set up an additional variable from simple kriging zDummy <- gstat(formula=z~1, locations = ~x+y, dummy=TRUE, beta=200, model=varioMod, nmax=1) # Generate a randomly autocorrelated predictor data field set.seed(123) xyz <- predict(zDummy, newdata=xy, nsim=2)
# [using unconditional Gaussian simulation]
We then add the spatial patterns into the grid to obtain two spatially autocorrelated rasters. The autocorrelated surfaces could, for example, represent the values of two plant functional traits in each cell.
# NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
Now we calculate multidimension Rao’s index for two different moving windows and alpha values.
The output is a nested list of RasterLayers which we can transform in a stack of RasterLayers and plot together with the input layers, as follows: