You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I might have found a bug when using the zonal() function with wide = FALSE. To illustrate the potential bug, please run the code below with the attached files? I've verified that this behavior is present with the latest version of terra on GitHub (1.7-41) and the latest version on CRAN (1.7-39). I have also included my session information below (with the latest GitHub version of terra).
Please let me know if there's any other information I can provide to help with this?
Reproducible example
# load packages
library(terra)
# load data
x <- terra::rast("pu.tif")
z <- terra::rast("country.tif")
# compute zonal statistics
z1 <- terra::zonal(x, z = z, fun = "sum", na.rm = TRUE, wide = TRUE)
z2 <- terra::zonal(x, z = z, fun = "sum", na.rm = TRUE, wide = FALSE)
# manaully compute correct result for 24th zone
terra::global(x * (z == 24), "sum", na.rm = TRUE)
#> sum
#> dem-100m-esri54017 1809
# display result for 24th zone computed with wide = TRUE
z1[z1$layer == 24, ]
#> layer dem-100m-esri54017
#> 23 24 1809
# display result for 24th zone computed with wide = FALSE
z2[z2$id == 24, ]
#> value layer id
#> 24.1 73 1 24
Hi,
I think I might have found a bug when using the
zonal()
function withwide = FALSE
. To illustrate the potential bug, please run the code below with the attached files? I've verified that this behavior is present with the latest version of terra on GitHub (1.7-41) and the latest version on CRAN (1.7-39). I have also included my session information below (with the latest GitHub version of terra).Please let me know if there's any other information I can provide to help with this?
Reproducible example
Data files
terra-issue.zip
Session information
The text was updated successfully, but these errors were encountered: