Nothing
#' spatRasterToDataset
#'
#' Convert a SpatRaster to a SpatRasterDataset.
#'
#' @param x SpatRaster with names of the form "y[0-9]+..[varname]"
#' @return SpatRasterDataset
#' @author Pascal Sauer
#' @export
spatRasterToDataset <- function(x) {
if (!requireNamespace("terra", quietly = TRUE)) {
stop("The package \"terra\" is required!")
}
if (all(grepl("^y[0-9]+\\.\\.", names(x)))) {
varnames <- unique(sub("^y[0-9]+\\.\\.", "", names(x)))
datasets <- lapply(varnames, function(varname) {
spatRaster <- x[paste0("\\.\\.", varname, "$")]
terra::varnames(spatRaster) <- varname
return(spatRaster)
})
} else {
varnames <- names(x)
datasets <- lapply(varnames, function(varname) {
spatRaster <- x[varname]
terra::varnames(spatRaster) <- varname
return(spatRaster)
})
}
x <- terra::sds(datasets)
names(x) <- varnames
return(x)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.