jbaileyh / geogrid

Turning geospatial polygons into regular or hexagonal grids. For other similar functionality see the tilemaps package https://github.com/kaerosen/tilemaps
Other
395 stars 31 forks source link

Examples: clean() error: no method for coercing S4 class to vector #12

Closed soedr closed 6 years ago

soedr commented 6 years ago

Hi there,

Thank you for making this package available. Trying to run through the example and encounter the below:

> result_df_raw <- clean(raw)
Error in as.vector(x) : no method for coercing this S4 class to a vector

Session info:


R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] hexmapr_0.0.0.1   packrat_0.4.8-1   gridExtra_2.3     units_0.4-6       udunits2_0.13     sf_0.5-5          rgeos_0.3-26     
 [8] rgdal_1.2-15      sp_1.2-5          Rcpp_0.12.13      magrittr_1.5      DBI_0.7           dplyr_0.7.4       plyr_1.8.4       
[15] viridis_0.4.0     viridisLite_0.2.0 ggplot2_2.2.1     devtools_1.13.3  

loaded via a namespace (and not attached):
 [1] compiler_3.4.2   bindr_0.1        class_7.3-14     tools_3.4.2      digest_0.6.12    memoise_1.1.0    tibble_1.3.4    
 [8] gtable_0.2.0     lattice_0.20-35  pkgconfig_2.0.1  rlang_0.1.2      yaml_2.1.14      bindrcpp_0.2     e1071_1.6-8     
[15] withr_2.0.0      classInt_0.1-24  grid_3.4.2       glue_1.1.1       R6_2.2.2         scales_0.5.0     assertthat_0.2.0
[22] colorspace_1.3-2 lazyeval_0.2.0   munsell_0.4.3
sassalley commented 6 years ago

Hi @soedr,

Thanks for testing the package. The clean function is just a wrapper around fortify and join which I use to convert theSpatialPolygonsDataFrame into something that can be used by ggplot2.

This process is discussed in more detail here. Is there any chance that you have other packages loaded that may have their own versions of join or fortify? For example, I believe this execution requires the plyr version of join and the function may be trying to use join from somewhere else?

(Trying plyr::join may help and potentially ggplot2::fortify since these functions also exist elsewhere).

soedr commented 6 years ago

Hi @sassalley, I just discovered that I missed your definition of clean() in the first example while going through the second example. My bad and sorry for the reduntant issue.

sassalley commented 6 years ago

@soedr no worries - thanks for engaging and trying out the package! I welcome any other thoughts.