isciences / exactextractr

R package for fast and accurate raster zonal statistics
https://isciences.gitlab.io/exactextractr/
272 stars 26 forks source link

exact_resample() drops error message #60

Closed amarbler closed 2 years ago

amarbler commented 2 years ago

Hi,

sorry to bother you again with the exact_resample function, but somehow the function doesn't work any longer and drops the following error both for raster and terra files:

library(exactextractr)
library(raster)
library(terra)

r = raster::raster(resolution = 2)
target = raster::shift(r, 2.5, 1)

set.seed(1111)
raster::values(r) = as.integer(round(rnorm(raster::ncell(r), 0, 1)))

rsmpld_raster = exactextractr::exact_resample(r, target, fun = "sum")
Error in CPP_resample(x, y, fun) :
  Cannot convert object to a function: [type=NULL; target=CLOSXP, SPECIALSXP, or BUILTINSXP].

rsmpld_terra = exactextractr::exact_resample(terra::rast(r), terra::rast(target), fun = "sum")
Error in CPP_resample(x, y, fun) :
  Cannot convert object to a function: [type=NULL; target=CLOSXP, SPECIALSXP, or BUILTINSXP].

R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 10 (buster)

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] terra_1.4-10        raster_3.5-1        sp_1.4-5
[4] exactextractr_0.7.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7.3       magrittr_2.0.1     units_0.7-2        tidyselect_1.1.1
 [5] lattice_0.20-45    R6_2.5.1           rlang_0.4.11       fansi_0.5.0
 [9] dplyr_1.0.7        tools_3.5.2        rgdal_1.5-27       grid_3.5.2
[13] utf8_1.2.2         KernSmooth_2.23-20 e1071_1.7-9        DBI_1.1.1
[17] ellipsis_0.3.2     class_7.3-19       assertthat_0.2.1   tibble_3.1.4
[21] lifecycle_1.0.1    crayon_1.4.1       sf_1.0-4           purrr_0.3.4
[25] vctrs_0.3.8        codetools_0.2-18   glue_1.4.2         proxy_0.4-26
[29] compiler_3.5.2     pillar_1.6.3       generics_0.1.0     classInt_0.4-3
[33] pkgconfig_2.0.3

exact_extract() still works...

dbaston commented 2 years ago

This is related to an update in the raster package (see #61). Fixed with f17f62f and in version 0.7.1 when it arrives on CRAN.