Ubuntu – How to install rgdal on Ubuntu 12.10

r

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)

Best Answer

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!

Related Question