2017-05-24 83 views
0

我一直在R中遇到一個導致程序崩潰的問題。我終於可以將問題縮小到以下範圍。rgeos/rgdal只有當rgdal而不是rgeos被加載時纔會出現bug

我發現了以下工作:

library(rgeos) 
x = readWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))") 
gIsValid(x) 
[1] TRUE 

然而,在發生碰撞的結果如下:

library(rgdal) 
x = rgeos::readWKT("POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))") 
rgeos::gIsValid(x) 

在R包我的工作,rgdal是「依賴下指定「和說明文件中的」Imports「下的rgeos。所以我的代碼表現得更像第二個(崩潰)場景。

下面是一些信息可能是有用的:

> library(rgeos) 
rgeos version: 0.3-23, (SVN revision 546) 
GEOS runtime version: 3.6.1-CAPI-1.10.1 r0 
Linking to sp version: 1.2-4 
Polygon checking: TRUE 

> library(rgdal) 
Loading required package: sp 
rgdal: version: 1.2-7, (SVN revision 660) 
Geospatial Data Abstraction Library extensions to R successfully loaded 
Loaded GDAL runtime: GDAL 1.11.5, released 2016/07/01 
Path to GDAL shared files: /usr/local/Cellar/gdal/1.11.5_2/share/gdal 
Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493] 
Path to PROJ.4 shared files: (autodetected) 
Linking to sp version: 1.2-4 
> sessionInfo() 
R version 3.4.0 (2017-04-21) 
Platform: x86_64-apple-darwin15.6.0 (64-bit) 
Running under: macOS Sierra 10.12.5 

Matrix products: default 
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.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] rgdal_1.2-7 sp_1.2-4  rgeos_0.3-23 

loaded via a namespace (and not attached): 
[1] compiler_3.4.0 grid_3.4.0  lattice_0.20-35 

如何這樣可以避免任何想法?這是geos中的錯誤嗎? GDAL?

+0

rgeosrgdal包是你餵養它的一小像上面或者是一大堆點來運行? – sconfluentus

+0

提供具有更多頂點的多邊形時,我發現了相同的行爲,如果這就是您的意思。 – Pascal

+0

解決方法當然是先加載rgeos包。 – Pascal

回答

0

最後,重新啓動電腦,重新安裝導致了這個代碼不再崩潰R.

相關問題