如何在 CentOS 6.8 安装 sf R 的包或 GDAL

How install sf R's package or GDAL at CentOS 6.8

我正在尝试通过行命令在 CentOS 6.8 服务器的 R 上安装 sf 包:

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

我收到了这条错误信息:

> install.packages('sf')
Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/sf_0.7-1.tar.gz'
Content type 'application/x-gzip' length 8330564 bytes (7.9 MB)
==================================================
downloaded 7.9 MB

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
configure: CC: gcc -m64 -std=gnu99
configure: CXX: g++ -m64 -std=gnu++0x
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 1.7.3
checking GDAL version >= 2.0.0... no
configure: error: sf is not compatible with GDAL versions below 2.0.0
ERROR: configuration failed for package ‘sf’
* removing ‘/usr/lib64/R/library/sf’

The downloaded source packages are in
        ‘/tmp/RtmpKDXg4S/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("sf") :
  installation of package ‘sf’ had non-zero exit status

看来我需要将 GDAL 升级到 2.0.0 或更高版本,但我不知道该怎么做。我在 CentOS 上通过命令行寻找安装(甚至升级)但一无所获。

我们将不胜感激。

感谢

对于那些登陆此页面希望找到在 RHEL 7.5 上安装 "sf" 的说明的人:

wget http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/u/udunits2-2.2.20-2.el7.x86_64.rpm
wget http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/u/udunits2-devel-2.2.20-2.el7.x86_64.rpm
yum install udunits2-devel-2.2.20-2.el7.x86_64.rpm
yum install udunits2-2.2.20-2.el7.x86_64.rpm

wget http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/g/geos-3.4.2-2.el7.x86_64.rpm
wget http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/g/geos-devel-3.4.2-2.el7.x86_64.rpm
yum install geos-*

wget http://download.osgeo.org/gdal/2.4.1/gdal-2.4.1.tar.gz
tar -zxvf gdal-2.4.1.tar.gz
cd gdal-2.4.1; 
./configure; make -j4; make install
echo "/usr/local/lib" /etc/ld.so.conf.d/libgdal-x86_64.conf
ldconfig
cp -p /usr/local/lib/libgdal.so.20* /usr/lib64/

cd ../
wget http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/p/proj-4.8.0-4.el7.x86_64.rpm
wget http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/p/proj-devel-4.8.0-4.el7.x86_64.rpm
yum install proj-4.8.0-4.el7.x86_64.rpm proj-devel-4.8.0-4.el7.x86_64.rpm

有些行可能是多余的,但这对我有用。

您需要最新的 GDAL 版本。包文档建议使用 docker https://r-spatial.github.io/sf/