协助在 Mac 上安装 'rgdal' 包

Assistance installing 'rgdal' package on Mac

如何在 MacOS Catalina 上安装 "rgdal" 软件包?

运行 代码如下:

 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'))

得到如下错误信息:

trying URL 'https://cran.rstudio.com/src/contrib/rgdal_1.4-8.tar.gz'
    Content type 'application/x-gzip' length 1698902 bytes (1.6 MB)
    ==================================================
    downloaded 1.6 MB
    * installing *source* package ‘rgdal’ ...
    ** package ‘rgdal’ successfully unpacked and MD5 sums checked
    configure: R_HOME: /Library/Frameworks/R.framework/Resources
    xcrun: error: invalid active developer path /Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    configure: C++11 support not available
    configure: rgdal: 1.4-7
    checking for /usr/bin/svnversion... yes
    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
    configure: svn revision: 845
    configure: gdal-config set to /Library/Frameworks/GDAL.framework/Programs/gdal-config
    checking gdal-config exists... no
    configure: error: gdal-config not found - configure argument error.
    ERROR: configuration failed for package ‘rgdal’
    * removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rgdal’
    Warning in install.packages :
      installation of package ‘rgdal’ had non-zero exit status

    The downloaded source packages are in
        ‘/private/var/folders/vz/0nmhj0qj27s_y3zjxjx6w3g40000gn/T/RtmpW2iTzA/downloaded_packages’

根据 Ish 的评论安装和使用 Homebrew。它将使此安装工作,并且您将能够避免在 MacOSX 上使用 R 包的其他常见安装错误。

在终端中安装 Homebrew 运行 'brew install gdal' 然后在 R 中使用安装包 'install.packages("rgdal", type="source")'