Skip to content

Commit 2e0b96b

Browse files
authored
Merge pull request #72 from Nowosad/master
fixes corner case
2 parents ba845f8 + 5dd1b87 commit 2e0b96b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

R/lsp_add_spatial.R

+5-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,11 @@ lsp_add_stars.lsp = function(x = NULL, window = NULL, metadata = TRUE){
104104
if (metadata_attr$use_window && is.null(window)){
105105
stop("This function requires an sf object in the window argument for irregular local landscapes.", call. = FALSE)
106106
}
107-
if (metadata_attr$window_shift == 0){
108-
output_stars = stars::st_as_stars(metadata_attr$bb, nx = 1, ny = 1, values = 1)
109-
names(output_stars) = "id"
107+
if (!is.null(metadata_attr$window_shift)){
108+
if (metadata_attr$window_shift == 0) {
109+
output_stars = stars::st_as_stars(metadata_attr$bb, nx = 1, ny = 1, values = 1)
110+
names(output_stars) = "id"
111+
}
110112
} else if (is.null(window)){
111113
output_stars = lsp_create_grid(x_crs = metadata_attr$crs,
112114
x_bb = metadata_attr$bb,

0 commit comments

Comments
 (0)