由于"gdal"导致安装"sf"的麻烦

inv*_*tus 19 r gdal

我无法在R上安装"sf"软件包.似乎gdal存在问题.不知道如何解决它.

> install.packages("sf")

  There is a binary version available but the source version is later:
   binary source needs_compilation
sf  0.4-3  0.5-1              TRUE

Do you want to install from sources the package which needs compilation?
y/n: y
installing the source package ‘sf’

trying URL 'https://cran.rstudio.com/src/contrib/sf_0.5-1.tar.gz'
Content type 'application/x-gzip' length 4073881 bytes (3.9 MB)
==================================================
downloaded 3.9 MB

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
configure: CC: clang
configure: CXX: clang++
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘sf’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/sf’
Warning in install.packages :
  installation of package ‘sf’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/1m/w_zt5ygd26n_87h41qf574wc0000gn/T/RtmpNlYbwT/downloaded_packages’
Run Code Online (Sandbox Code Playgroud)

为什么说下载失败,然后说下载了源包.是什么赋予了?

Rgr*_*and 16

面对类似的问题,我遵循以下步骤:

  1. 在终端:gdalinfo --version检查你有哪个gdal版本.我的是GDAL 2.2.0,2017年4月28日发布后brew update,并brew upgrade
  2. 从这里:https://github.com/r-spatial/sf,macOS的说明,因为我已经安装了gdal,我只使用brew unlink gdal然后brew link --force gdal2
  3. 我在R上重新安装了rgdal:install.packages("rgdal", repos = "http://cran.us.r-project.org", type = "source")我已经确认它是用configure编译的:GDAL:2.2.0
  4. 最后,install.packages("sf")它需要编译:binary source needs_compilation sf 0.5-3 TRUE
  5. 我再次确认configure:GDAL:2.2.0并检查GDAL版本> = 2.0.0 ...是的

之后,我安装了新版本: library(sf) 链接到GEOS 3.6.2,GDAL 2.2.0,proj.4 4.9.3

我希望它也可以成为你的解决方案.

  • `rgdal::getGDALVersionInfo(str = "--version")` 可让您确定 rgdal 中使用的 GDAL 版本。 (2认同)