mdsumner / spex

Spatial extent tools
https://mdsumner.github.io/spex/
21 stars 2 forks source link

polygonize: Error in vapply(lst, class, rep(NA_character_, 3)) : values must be length 3, but FUN(X[[1]]) result is length 1 #12

Closed adrfantini closed 6 years ago

adrfantini commented 6 years ago

If running the example code in spex::polygonize(), you get the following error:

library(sf)
library(spex)
library(raster)
r <- raster(volcano)
r[sample(ncell(r), 3000)] <- NA
b <- brick(r, r*1.5)
psf <- qm_rasterToPolygons(r, na.rm = TRUE)
psf
Error in vapply(lst, class, rep(NA_character_, 3)) : 
  values must be length 3,
 but FUN(X[[1]]) result is length 1

This is true also for other rasters when trying to polygonize() them.

adrfantini commented 6 years ago

Still get this! Any idea what is causing it?

mdsumner commented 6 years ago

Can you try now from master? (Please also first give a sessionInfo() so there's a record of the env you saw this)

I can't reproduce, and that vapply is sf code

adrfantini commented 6 years ago

It's fixed!

sessionInfo:

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Arch Linux

Matrix products: default
BLAS/LAPACK: /usr/lib/libopenblas_haswellp-r0.2.20.so

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

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

other attached packages:
[1] raster_2.6-7   sp_1.2-7       spex_0.4.0     sf_0.6-2       pacman_0.4.6  
[6] colorout_1.1-2

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.16      bindr_0.1         magrittr_1.5      devtools_1.13.4  
 [5] units_0.5-1       lattice_0.20-35   R6_2.2.2          rlang_0.2.0.9001 
 [9] udunits2_0.13     httr_1.3.1        dplyr_0.7.4       tools_3.4.4      
[13] grid_3.4.4        e1071_1.6-8       DBI_0.8           git2r_0.21.0     
[17] withr_2.1.1.9000  class_7.3-14      assertthat_0.2.0  RPostgreSQL_0.6-2
[21] digest_0.6.15     tibble_1.4.2      bindrcpp_0.2      curl_3.1         
[25] glue_1.2.0        memoise_1.1.0     quadmesh_0.1.0    pillar_1.2.1     
[29] compiler_3.4.4    classInt_0.1-24   pkgconfig_2.0.1