0

有没有其他人在使用 rmapshaper 包中的 ms_simplify 函数时看到以下错误?

foo = rmapshaper::ms_simplify(rworldmap::countriesLow)

Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv,  : Cannot open data source

我试图在我的工作区中的 .shp 文件上运行该函数并得到相同的错误。

> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.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.4/Resources/lib/libRlapack.dylib

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

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

loaded via a namespace (and not attached):
[1] Rcpp_0.12.16       rmapshaper_0.3.0   magrittr_1.5       hms_0.4.1          maptools_0.9-2     maps_3.2.0        
[7] jsonvalidate_1.0.0 lattice_0.20-35    R6_2.2.2           rlang_0.2.0.9001   httr_1.3.1         fields_9.6        
[13] tools_3.4.3        dotCall64_0.9-5.2  rgdal_1.2-18       grid_3.4.3         spam_2.1-2         geojson_0.2.0     
[19] jqr_1.0.0          rgeos_0.3-26       lazyeval_0.2.1     tibble_1.4.2       geojsonio_0.5.0    readr_1.1.1       
[25] curl_3.1           sp_1.2-7           rworldmap_1.3-6    V8_1.5             pillar_1.1.0       compiler_3.4.3    
[31] geojsonlint_0.2.0  jsonlite_1.5       foreign_0.8-69     pkgconfig_2.0.1 
4

1 回答 1

0

该问题似乎是由于 rgdal 库最近发生了变化。有关更多信息,请参阅:https ://github.com/ateucher/rmapshaper/issues/74

使用 rmapshaper 包的开发版本修复了这个问题:

# install.packages("devtools")`
devtools::install_github("ropensci/geojsonio")
devtools::install_github("ateucher/rmapshaper")

foo = rmapshaper::ms_simplify(rworldmap::countriesLow)
plot(foo)
于 2018-04-02T15:18:08.367 回答