How to install rgdal on Ubuntu 12.10?
I'm strugling to install rgdal
library on Ubuntu 12.10.
Installation from within R results in error:
Error: gdal-config not found The gdal-config script distributed with GDAL could not be found. If you have not installed the GDAL libraries, you can download the source from http://www.gdal.org/ If you have installed the GDAL libraries, then make sure that gdal-config is in your path. Try typing gdal-config at a shell prompt and see if it runs. If not, use: --configure-args='--with-gdal-config=/usr/local/bin/gdal-config' with appropriate values for your installation.
ERROR: configuration failed for package ‘rgdal’ * removing ‘/home/rdk/R/x86_64-pc-linux-gnu-library/2.15/rgdal’ Warning in install.packages : installation of package ‘rgdal’ had non-zero exit status
R-sig-Geo, this two SE questions and other websites pointed me to the requirements of libgdal1-dev
.
But when I tried
sudo apt-get install libgdal1-dev
I end up with another error message
Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation:
The following packages have unmet dependencies: libgdal1-dev : Depends: libgdal-dev but it is not going to be installed E: Unable to correct problems, you have held broken packages.
Again - when I try to install libgdal-dev
another dependencies error shows up
The following packages have unmet dependencies: libgdal-dev : Depends: libgeos-dev but it is not going to be installed Depends: libspatialite-dev but it is not going to be installed
Again trying libgeos-dev
gives message:
Depends: libgeos-c1 (= 3.3.3-1.1) but 3.3.3-2~precise2 is to be installed
E: Unable to correct problems, you have held broken packages.
and libspatialite-dev
:
Depends: libspatialite3 (= 3.1.0~rc2-1ubuntu1) but
3.1.0~rc2-2~precise1 is to be installed
Is there any way to tame those dependencies and have rgdal
running in Ubuntu?
My sessionInfo()
R version 2.15.1 (2012-06-22) Platform: x86_64-pc-linux-gnu (64-bit)
Solution 1:
A more recent answer can be found here: http://robinlovelace.net/r/2013/11/26/installing-rgdal-on-ubuntu.html .
Essentially, the three following lines of code should sort it:
sudo apt-get install aptitude # install aptitude as an alternative to apt-get
sudo aptitude install libgdal-dev # install the package (you may have to respond to queries here)
sudo aptitude install libproj-dev # install the proj.4 projection library
Spent ages on this problem, so hope this updated answer is useful to others. Let me know if so!
Solution 2:
Try running them all together and specifying the versions, like this:
sudo apt-get install libgdal1-dev libgdal-dev libgeos-c1=3.3.3-1.1 libspatialite3=3.1.0~rc2-1ubuntu1
apt-get does not like to downgrade packages, but it will if you specify it.
Solution 3:
Here in January 2016, on Ubuntu 14.04.2 (and with R 3.2.2), I needed the following to get both rgdal and the complementary (and frequently very useful) gdalUtils package installed:
sudo apt-get update
sudo apt-get -y install libgdal1h
sudo apt-get -y install libgdal1-dev
sudo apt-get install libproj-dev
sudo apt-get install gdal-bin
Rscript 'install.packages(c("rgdal", "gdalUtils"))'
Update: As on January 2017, the version of libgdal is 1i, so the second line of code should read:
sudo apt-get -y install libgdal1i