在 ubuntu 16.04 上安装 rgdal 时遇到问题

trouble in installing rgdal on ubuntu 16.04

我一直在尝试在 R 3.4.2 (RStudio 1.1.383) 和 ubuntu 16.04 上安装 rgdal,但它总是以问题告终。

我遵循了许多建议,例如手动安装 libproj-dev 等依赖项,或者我最后一次尝试使用 homebrew

我可以安装 gdal 1.11.3,但还不够。

这是我写

时的输出
    install.packages('rgdal', type = "source", configure.args=c('--with-proj-include=/usr/local/include','--with-proj-lib=/usr/local/lib'))

Installing package into ‘/home/tupac/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
essai de l'URL 'https://cran.rstudio.com/src/contrib/rgdal_1.2-15.tar.gz'
Content type 'application/x-gzip' length 1648779 bytes (1.6 MB)
==================================================
downloaded 1.6 MB

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ correctement décompressé et sommes MD5 vérifiées
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: rgdal: 1.2-15
checking for /usr/bin/svnversion... no
configure: svn revision: 691
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 1.11.3
checking GDAL version >= 1.6.3... yes
checking gdal: linking with --libs only... yes
checking GDAL: /usr/share/gdal/1.11/pcs.csv readable... yes
configure: -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -I/usr/local/include 
checking proj_api.h presence and usability... no
configure: error: proj_api.h not found in standard or given locations.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/home/tupac/R/x86_64-pc-linux-gnu-library/3.4/rgdal’
Warning in install.packages :
  installation of package ‘rgdal’ had non-zero exit status

在同一个 post 中也发现了错误 "proj_api.h not found",但给出的解决方案在我的情况下不起作用,但它似乎适用于许多其他用户。

感谢您帮助我解决这个问题。

我终于找到了解决办法。

我按照这个post

的回答

奇迹密码是

sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
sudo apt update
sudo apt install gdal-bin python-gdal python3-gdal libgdal1-dev

感谢您的帮助