无法安装rgdal

时间:2015-12-17 11:36:44

标签: r macos gdal rgdal

我想为rgdal安装"R version 3.2.3 (2015-12-10)"。 我下载并安装了

  • GDAL 1.11完成
  • PROJ framework v4.9.2-2
  • GEOS framework v3.5.0-1

来自KyngChaos

然后在RStudio中输入了install.packages("rgdal"),它给了我这个:

> .... 
> 
> configure: CC: clang configure: CXX: clang++ configure: rgdal:
> 1.1-1 checking for /usr/bin/svnversion... yes configure: svn revision: 
> 572 checking for gdal-config... 
> no no configure: error: gdal-config
> not found or not executable. ERROR: configuration failed for package
> ‘rgdal’
> * removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rgdal’
> Warning in install.packages :   installation of package ‘rgdal’ had
> non-zero exit status

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.5 (Yosemite)

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

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

loaded via a namespace (and not attached):
[1] tools_3.2.3

我也尝试过终端

R CMD INSTALL rgdal_1.1-1.tar --configure-args='--with-gdal-config=/Library/Frameworks/GDAL.framework/Programs/gdal-config
 --with-proj-include=/Library/Frameworks/PROJ.framework/Headers
 --with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib'

sudo R CMD INSTALL –configure-args=’–with-proj-include=/usr/local/lib’ rgdal_1.1-1.tar

没有运气!

4 个答案:

答案 0 :(得分:22)

终于解决了它。

以下是我如何做到的! OS X 10.10.5 R 3.2.3 GDAL 1.1

  1. here
  2. 下载并安装GDAL完整框架
  3. 通过在shell中键入此文件,告诉您的OS X在哪里找到gdal-config文件 echo 'export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH' >> ~/.bash_profile然后source ~/.bash_profile
  4. 输入bash gdalinfo --version,检查您的GDAL是否正常工作。这应该与GDAL 1.11.3, released 2015/09/16之类的东西一样。
  5. 对于大多数人来说,启动R并键入install.packages("rgdal")有效(如果您已完成步骤1-3)。但是,对我来说情况并非如此。所以,如果你还有麻烦,请继续进行。
  6. 转到GDAL网站并下载.tar文件。
  7. 在shell中,试试这个:sudo R CMD INSTALL –configure-args=’–with-proj-include=/usr/local/lib’ rgdal_1.1-1.tar。这仍然给了我一个错误:configure: error: proj_api.h not found in standard or given locations. ERROR: configuration failed for package ‘rgdal’
  8. 所以,你再次需要告诉在哪里找到那个。尝试: R CMD INSTALL rgdal_1.1-1.tar --configure-args='--with-gdal-config=/Library/Frameworks/GDAL.framework/Programs/gdal-config --with-proj-include=/Library/Frameworks/PROJ.framework/Headers --with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib'
  9. 那应该有用。尝试启动R并输入library(rgdal)

    注意:rgoes我遇到了类似的问题。 This帮助了我。 试试:

    R CMD INSTALL rgeos_0.3-15.tar --configure-args='--with-geos-config=/Library/Frameworks/GEOS.framework/unix/bin/geos-config
    --with-proj-include=/Library/Frameworks/PROJ.framework/Headers
    --with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib'
    

    用于指向config文件。它在这里/Library/Frameworks/GEOS.framework/unix/bin/geos-config

答案 1 :(得分:16)

快速记录@Stophface之前的回答,可能对某人有用:

我做了上面列出的所有步骤,但是终端中的rgdal安装仍然给了我configure: error: proj_api.h not found in standard or given locations的错误。然而(并且不知道究竟为什么),我设法使用几乎相同的规范从R.app安装它:

> install.packages('rgdal', type = "source", configure.args=c(
     '--with-gdal-config=/Library/Frameworks/GDAL.framework/Programs/gdal-config',
     '--with-proj-include=/Library/Frameworks/PROJ.framework/Headers',
     '--with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib'))

再次感谢您的回答!

答案 2 :(得分:5)

我在macOS Sierra(10.12)上运行R 3.4.0时遇到了同样的错误。所以我用自制软件安装gdal,然后按照惯例安装rgdal在R

中 终端

中的

brew update
brew install gdal

在R

install.packages("rgdal")
devtools::session_info()
Session info ----------------------------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.0 (2017-04-21)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.0.143)           
 language (EN)                        
 collate  en_AU.UTF-8                 
 tz       Australia/Melbourne         
 date     2017-04-24                  

Packages --------------------------------------------------------------------------------------------------------------------------------------------------
 package  * version date       source        
 devtools   1.12.0  2016-12-05 CRAN (R 3.4.0)
 digest     0.6.12  2017-01-27 CRAN (R 3.4.0)
 lattice    0.20-35 2017-03-25 CRAN (R 3.4.0)
 memoise    1.1.0   2017-04-21 CRAN (R 3.4.0)
 rgdal    * 1.2-6   2017-04-06 CRAN (R 3.4.0)
 sp       * 1.2-4   2016-12-22 CRAN (R 3.4.0)
 withr      1.0.2   2016-06-20 CRAN (R 3.4.0)

答案 3 :(得分:1)

我通过我的Mac上的conda安装它(OS X 10.10.5)。安装很简单。如果您是康达新手,请查看此http://conda.pydata.org/docs/r-with-conda.html

conda install gdal
gdalinfo --version
# GDAL 2.1.0, released 2016/04/25

R包安装:

install.packages('rgdal', type = "source", configure.args=c(
    '--with-gdal-config=/Library/Frameworks/GDAL.framework/Programs/gdal-config',
    '--with-proj-include=/Library/Frameworks/PROJ.framework/Headers',
    '--with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib'))

install.packages('rgeos', type = "source", configure.args=c(
    '--with-gdal-config=/Library/Frameworks/GDAL.framework/Programs/gdal-config',
    '--with-proj-include=/Library/Frameworks/PROJ.framework/Headers',
    '--with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib'))

install.packages('maptools', dependencies=TRUE)