Skip to content

Commit

Permalink
setting snap to out to crop rasters by default (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
goergen95 authored Dec 6, 2023
1 parent 640f93d commit 58b696f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- `calc_indicators()` now includes a check for 0-length tibbles (#199, #216)
- .read_raster_source now uses a single logic to cover all cases (e.g. single tiles,
tiled rasters with and without temporal dimension, single temporal rasters)
- cropping rasters now uses `snap="out"` by default
- .read_raster_source now projects assets in case their CRS differs from the raster


Expand Down
2 changes: 1 addition & 1 deletion R/calc_indicators.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ calc_indicators <- function(x, indicators, ...) {
out <- do.call(c, out)

# crop the source to the extent of the current polygon
cropped <- try(terra::crop(out, terra::vect(x)))
cropped <- try(terra::crop(out, terra::vect(x), snap = "out"))
if (inherits(cropped, "try-error")) {
warning(as.character(cropped))
return(NULL)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-calc_indicator.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ test_that("Parallelization works", {

expect_equal(
stat,
c(2603.803, 2600.664, 2596.358, 2557.306, 2540.299, 2532.707),
c(2656.062, 2652.923, 2648.616, 2609.273, 2592.046, 2584.090),
tolerance = 1e-3
)
})
Expand Down

0 comments on commit 58b696f

Please sign in to comment.