#' @title Extract phenological metrics
#' @description Internal function to bypass an encountered error:
#' sometimes (apparently with large stacks) returns stars_proxy
#' instead than stars: in this case, manually build a stars object.
#' @param src object of class `stars` with source raster
#' @param dest object of class `stars` with target raster geometry
#' @param ... Additional arguments passed to `stars::st_warp()`.
#' @author Luigi Ranghetti, PhD (2020) \email{luigi@@ranghetti.info}
#' @importFrom stars st_warp st_redimension
st_warp_fixing <- function(src, dest, ...) {
stars_cube <- st_warp(src, dest, ...)
if (inherits(stars_cube, "stars_proxy")) {
stars_length <- dim(stars_cube)[3]
stars_list <- list()
for (i in seq_len(stars_length)) {
stars_list[[i]] <- st_warp(src[,,,i], dest[,,,i], ...)
}
stars_cube <- st_redimension(
do.call(c, stars_list),
along = list(band = seq_len(stars_length))
)
}
stars_cube
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.