rvalavi / blockCV

The blockCV package creates spatially or environmentally separated training and testing folds for cross-validation to provide a robust error estimation in spatially structured environments. See
https://doi.org/10.1111/2041-210X.13107
GNU General Public License v3.0
106 stars 22 forks source link

error in spatialBlock #16

Closed AMBarbosa closed 3 years ago

AMBarbosa commented 3 years ago

Dear Roozbeh,

Lately I'm getting an error when running 'spatialBlock' (tried already with several sets of species points + raster layer) like this: blocks <- spatialBlock(speciesData = myPoints, rasterLayer = myLayers[[1]], theRange = mySpatialAutoRange$range, k = 5)

I've tried debugging and found out that everything runs correctly almost until the end, and the error occurs within the command to make 'theList', when running 'sf::as_Spatial(subBlocks)':

Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'addAttrToGeom': no arguments in initialization list

sessionInfo() R version 4.0.3 (2020-10-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale: [1] LC_COLLATE=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252
[3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Portugal.1252

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

other attached packages: [1] raster_3.3-13 sp_1.4-4 blockCV_2.1.1 modEvA_2.0

loaded via a namespace (and not attached): [1] Rcpp_1.0.5 compiler_4.0.3 pillar_1.4.6
[4] prettyunits_1.1.1 class_7.3-17 tools_4.0.3
[7] progress_1.2.2 lifecycle_0.2.0 tibble_3.0.4
[10] gtable_0.3.0 lattice_0.20-41 pkgconfig_2.0.3
[13] rlang_0.4.8 DBI_1.1.0 cli_2.1.0
[16] rstudioapi_0.11 rgdal_1.4-8 parallel_4.0.3
[19] e1071_1.7-4 dplyr_1.0.2 generics_0.0.2
[22] dbarts_0.9-17 vctrs_0.3.4 hms_0.5.3
[25] classInt_0.4-3 grid_4.0.3 tidyselect_1.1.0
[28] glue_1.4.2 sf_0.9-6 R6_2.5.0
[31] fansi_0.4.1 farver_2.0.3 purrr_0.3.4
[34] ggplot2_3.3.2 magrittr_1.5 scales_1.1.1
[37] codetools_0.2-16 ellipsis_0.3.1 units_0.6-7
[40] assertthat_0.2.1 colorspace_1.4-1 KernSmooth_2.23-17 [43] munsell_0.5.0 crayon_1.3.4

AMBarbosa commented 3 years ago

Fixed by updating rgdal after reding this #https://github.com/r-spatial/sf/issues/1529#issuecomment-724793559