R 3.5 上的 SF 找不到正确版本的 gdal

SF on R 3.5 can't find correct version of gdal

我在 Centos 7 上安装了 sf 包并在 r 3.4.3 上工作。获得正确版本的 GDAL 很复杂,但它正在工作,我能够使用 tidycensus 制作地图。

然而,当我升级到 R 3.5 然后尝试升级或重新安装 sf 时,我开始收到此消息:

checking for gdal-config...

/bin/gdal-config checking gdal-config usability... yes

configure: GDAL: 1.11.4 checking GDAL version >= 2.0.0... no

configure: error: sf is not compatible with GDAL versions below 2.0.0

但是我确实安装了 GDAL 2,事实证明它之前可以正常工作加上如果我这样做 gdalinfo --version 我得到

GDAL 2.2.3, released 2017/11/20

我确实阅读了很多 SO 问题,发现 RDGAL 是用 1.11.4 版本编译的,我认为 sf 依赖于它。但是我还没有在 Centos 上找到强制它使用 GDAL 2.2.3 的方法。我已经删除并重新安装了 rdgal 但它没有帮助,它总是使用 1.1 重新安装。

 rgdal::getGDALVersionInfo(str = "--version")

好吧,我不太确定这是否是整个解决方案,但根据 this page 上的评论,我这样做了:

R CMD INSTALL -l ~/R/x86_64-redhat-linux-gnu-library/3.1 
--configure-args='
--with-gdal-config path/to/software/dir/bin/gdal-config 
--with-proj-include path/to/software/dir/include 
--with-proj-lib path/to/software/dir/lib 
--with-proj-data path/to/software/dir/share/proj 
--with-data-copy=yes' rgdal

它奏效了。不过,我在这两者之间做了其他可能有所帮助的事情。

更新: 使用更新的 R 到 3.6 进行同样的操作,我发现如果我删除 rgdal 并重新安装(没有特殊选项),我能够成功安装 sf。