diff --git a/R/lsp_add_spatial.R b/R/lsp_add_spatial.R index 4553883..638b752 100644 --- a/R/lsp_add_spatial.R +++ b/R/lsp_add_spatial.R @@ -58,6 +58,9 @@ lsp_add_stars.default = function(x = NULL, window = NULL){ } if (is.numeric(window) && window != 0){ + if (inherits(x, "SpatRaster")){ + x = stars::st_as_stars(x) + } x_crs = sf::st_crs(x) x_bb = sf::st_bbox(x) x_delta_row = stars::st_dimensions(x)[[1]][["delta"]] @@ -203,7 +206,7 @@ lsp_add_terra = function(x = NULL, window = NULL){ if (!requireNamespace("terra", quietly = TRUE)){ stop("package terra required, please install it first") # nocov } - output = lsp_add_stars(x = stars::st_as_stars(x), window = window) + output = lsp_add_stars(x = x, window = window) output_names = names(output) output = terra::rast(output) names(output) = output_names