9

My Ubuntu machine has latest GDAL (2.2.1, released 2017/06/23). But R complains that I have gdalversion <2.0

configure: CC: gcc -std=gnu99
configure: CXX: g++
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 1.11.3
checking GDAL version >= 2.0.0... no
configure: error: sf is not compatible with GDAL versions below 2.0.0 

How can I direct R to access GDAL (2.2.1 version) already installed on Ubuntu?

user438383
  • 5,716
  • 8
  • 28
  • 43
sbaniwal
  • 337
  • 4
  • 6

2 Answers2

30

You may need to uninstall all traces of gdal then re-install it from the ubuntugis-unstable source. The following helped me solve a similar problem:

sudo apt remove libgdal-dev
sudo apt remove libproj-dev
sudo apt remove gdal-bin
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable

Make sure a version >= 2.0 appears when you execute this line:

sudo apt-cache policy libgdal-dev

If so, run:

sudo apt update
sudo apt install libgdal-dev

I could then successfully execute in R 3.4.2 in Ubuntu 14.04 ("Trusty Tahr") this:

install.packages('rgdal')
matmar
  • 318
  • 2
  • 13
Rick Pack
  • 1,044
  • 10
  • 20
  • 2
    I agree with @HugoKoopmans: Should add apt-get update before the apt-cache policy libgdal-dev to make sure it's the required version. – oatmilkyway Nov 24 '18 at 18:56
  • 1
    The stable repository has a gdal 2.1.3 version, so you can add the stable repository instead of the unstable with: sudo add-apt-repository ppa:ubuntugis/ppa – Oziel Carneiro Dec 12 '18 at 19:32
  • 1
    I had to use the unstable ppa today to install. Note to self, remove ppa at the command line later using these instructions: https://itsfoss.com/how-to-remove-or-delete-ppas-quick-tip/ – geneorama Mar 12 '19 at 22:13
  • Actually getting a compile error now `/usr/include/projects.h:148:33: error: conflicting types for ‘projUV’`. Sad. – geneorama Mar 12 '19 at 22:15
  • Further note to self: Followed previous notes to self here https://stackoverflow.com/questions/12141422/error-gdal-config-not-found and still had the exact same problems. – geneorama Mar 12 '19 at 22:30
  • 1
    Adding the stable repository version worked for me on Ubuntu trusty 14.04.6 LTS – peixe Sep 19 '19 at 13:16
1

The following worked for me

sudo apt-get install gdal-bin proj-bin libgdal-dev libproj-dev

From: https://gist.github.com/dncgst/111b74066eaea87c92cdc5211949cd1e

Antonio
  • 563
  • 1
  • 5
  • 12