r-tmap / tmap

R package for thematic maps
https://r-tmap.github.io/tmap
GNU General Public License v3.0
865 stars 121 forks source link

pj_obj_create: Cannot find proj.db #440

Closed oggioniale closed 4 years ago

oggioniale commented 4 years ago

Dear, I obtain some of this pj_obj_create: Cannot find proj.db when I execute this:

biomeColor <- tibble::tribble(
  ~geoBonBiome, ~fill, ~border,
  "marine", "#055ca8", "#057ae1",
  "coastal", "#43903f", "#5ecc58",
  "fresh_water_lakes", "#03a3b8", "#04d0eb",
  "terrestrial", "#b07c03", "#e8a303"
)

deimsid <- 'https://deims.org/f30007c4-8a6e-4f11-ab87-569db54638fe'
geoBonBiome <- jsonlite::fromJSON(paste0("https://deims.org/", "api/sites/", substring(deimsid, 19)))$attributes$environmentalCharacteristics$geoBonBiome
color <- biomeColor$fill[biomeColor$geoBonBiome == geoBonBiome]
colorBorder <- biomeColor$border[biomeColor$geoBonBiome == geoBonBiome]
geoBoundaries <- jsonlite::fromJSON(paste0("https://deims.org/", "api/sites/", substring(deimsid, 19)))$attributes$geographic$boundaries
lterCoords <- jsonlite::fromJSON(paste0("https://deims.org/", "api/sites/", substring(deimsid, 19)))$attributes$geographic$coordinates
lterSitesFeatureDEIMS <- sf::as_Spatial(sf::st_as_sfc(geoBoundaries),)
lterSitesFeatureDEIMS@proj4string <- sp::CRS('+proj=longlat +datum=WGS84 +no_defs')
baseMap <- rosm::osm.raster(lterSitesFeatureDEIMS)
# plot(baseMap)
newBaseMap <- raster::reclassify(baseMap, cbind(NA, 255))
# plot(newBaseMap)
mapOfSite <-
      tmap::tm_shape(newBaseMap, ) + tmap::tm_rgb() +
      tmap::tm_shape(lterSitesFeatureDEIMS) +
      tmap::tm_borders(col = colorBorder) +
      tmap::tm_fill(col = color)
mapOfSite

My sessionInfo() is:

R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.15.3

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.5/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] raster_3.1-5 sp_1.4-1     tibble_3.0.1 sf_0.9-3    

loaded via a namespace (and not attached):
 [1] xfun_0.13          lattice_0.20-41    colorspace_1.4-1   vctrs_0.2.4        htmltools_0.4.0   
 [6] stars_0.4-1        viridisLite_0.3.0  base64enc_0.1-3    XML_3.99-0.3       rlang_0.4.6       
[11] e1071_1.7-3        pillar_1.4.4       glue_1.4.0         DBI_1.1.0          RColorBrewer_1.1-2
[16] lifecycle_0.2.0    plyr_1.8.6         munsell_0.5.0      htmlwidgets_1.5.1  codetools_0.2-16  
[21] leafsync_0.1.0     knitr_1.28         tmap_3.0           crosstalk_1.1.0.1  curl_4.3          
[26] parallel_3.5.1     class_7.3-17       fansi_0.4.1        leafem_0.1.1       Rcpp_1.0.4.6      
[31] KernSmooth_2.23-17 scales_1.1.0       classInt_0.4-3     lwgeom_0.2-3       leaflet_2.0.3     
[36] jsonlite_1.6.1     abind_1.4-5        png_0.1-7          packrat_0.5.0      digest_0.6.25     
[41] rosm_0.2.5         tmaptools_3.0      grid_3.5.1         rgdal_1.4-8        cli_2.0.2         
[46] tools_3.5.1        magrittr_1.5       dichromat_2.0-0    crayon_1.3.4       pkgconfig_2.0.3   
[51] ellipsis_0.3.0     assertthat_0.2.1   rstudioapi_0.11    R6_2.4.1           units_0.6-6       
[56] compiler_3.5.1 

I tried to re-installing tmap, tmaptools, sf, and rgdal following this documentation but the GDAL, PROJ and GEOS are: Linking to GEOS 3.8.1, GDAL 2.4.4, PROJ 7.0.0

any idea?

lbusett commented 4 years ago

Works for me on Windows.

The "proj.db" error is often related with problems on GDAL/PROJ versions. In your case, the combination GDAL2.4 / PROJ7 seems possibly "problematic" to me.