The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
library(terra)
library(gstat)
library(rasterdiv)
library(rasterVis)
library(viridis)
In this vignette, we demonstrate how to compute the multidimensional Rao’s Index using rasterdiv for multiple numerical matrices, represented as spatially autocorrelated SpatRaster objects.
We now calculate the multidimensional Rao’s Index using varying window sizes and alpha values.
paRao(x=list(r, r1), window=c(3, 5), alpha=c(1, Inf), na.tolerance=1, method="multidimension", simplify=3) mRao <-
The output is a nested list of SpatRaster which we can transform in a stack of SpatRaster and plotted together with the input layers, as follows:
# Create a list of all the rasters to plot
c(r, r1, mRao[[1]]$alpha.1, mRao[[2]]$alpha.Inf)
rasters_to_plot <-names(rasters_to_plot) <- c("Raster1", "Raster2", "Rao_Index_Window_3", "Rao_Index_Window_5")
# Use lapply to create a list of levelplots
lapply(rasters_to_plot, function(rst) {
plots_list <-levelplot(as.matrix(rst, wide=TRUE), margin=FALSE,
col.regions=magma(100),
main=list(label=names(rst),
cex=1.5))
})
# Arrange the plots in a grid
do.call(gridExtra::grid.arrange, c(plots_list, ncol = 2))
Now, we demonstrate how to compute the multidimensional Rao’s Index for a time series of rasters accounting for phenology, and compare it with Rao’s Index on the same time series without a distance metrics that account for phenology.
# Calculate Phenological Rao's Index using TWDTW
paRao(x = raster_ts,
RaoPhen <-window = 5,
alpha = 2,
na.tolerance = 0,
time_vector = dates,
method = "multidimension",
dist_m = "twdtw",
np = 7, progBar = FALSE)
# Calculate Rao's Index using Euclidean distance
paRao(x = raster_ts,
RaoEuc <-window = 5,
alpha = 2,
na.tolerance = 0,
method = "multidimension",
dist_m = "euclidean",
np = 7, progBar = FALSE)
The key takeaway is that by accounting for seasonality in our index time series, we can reduce artifact hotspots in Rao’s index. These hotspots often arise from transitions between areas with high spatial variability and those with low spatial variability, which are not due to plant phenology but to buildings or other human-made objects. This effect is illustrated by the square area in the centre of the plot below.
# Visualization
levelplot(mean(raster_ts), margin = FALSE,
raster_ts_plot <-col.regions = viridis(100),
main = list(label = "Average index",
cex = 1.5))
levelplot(RaoPhen[[1]][[1]], margin = FALSE,
RaoP_plot <-col.regions = viridis(100),
main = list(label = "Phenological Rao",
cex = 1.5))
levelplot(RaoEuc[[1]][[1]], margin = FALSE,
Rao_plot <-col.regions = viridis(100),
main = list(label = "Rao",
cex = 1.5))
do.call(gridExtra::grid.arrange, c(list(raster_ts_plot, Rao_plot, RaoP_plot), ncol = 3))
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.