From 5dd1b87a24d577f61116b33f1d83c534a17156cb Mon Sep 17 00:00:00 2001 From: Jakub Nowosad Date: Sun, 14 Apr 2024 16:25:16 +0200 Subject: [PATCH] fixes corner case --- R/lsp_add_spatial.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/lsp_add_spatial.R b/R/lsp_add_spatial.R index 712e909..40ad7fe 100644 --- a/R/lsp_add_spatial.R +++ b/R/lsp_add_spatial.R @@ -104,9 +104,11 @@ lsp_add_stars.lsp = function(x = NULL, window = NULL, metadata = TRUE){ if (metadata_attr$use_window && is.null(window)){ stop("This function requires an sf object in the window argument for irregular local landscapes.", call. = FALSE) } - if (metadata_attr$window_shift == 0){ - output_stars = stars::st_as_stars(metadata_attr$bb, nx = 1, ny = 1, values = 1) - names(output_stars) = "id" + if (!is.null(metadata_attr$window_shift)){ + if (metadata_attr$window_shift == 0) { + output_stars = stars::st_as_stars(metadata_attr$bb, nx = 1, ny = 1, values = 1) + names(output_stars) = "id" + } } else if (is.null(window)){ output_stars = lsp_create_grid(x_crs = metadata_attr$crs, x_bb = metadata_attr$bb,