1

Two part question:

1) Like the person who asked this question (rgdal won't install on AWS RStudio AMI), I'm running into problems installing the rgdal package on R running on Ubuntu 16.04. The package wants GDAL 1.11.4 or later, and Synaptic Package manager is only offering GDAL 1.11.3.

The solution offered on the above question is to install an older version of rgdal from the archive. On the other hand, the answer given to this older question (Trouble getting latest version of GDAL on ubuntu running R) is to install a more recent version of GDAL from ubuntu-unstable.

Do both of these approaches work?

2) What are the steps required for each approach (or the approach that works if they don't both work)?

user1521655
  • 486
  • 3
  • 17
  • I'd just install a recent `gdal` from source. Download the tarball from here: http://download.osgeo.org/gdal/2.3.1/. Move the file under `/usr/local`, then (from /usr/local) give the usual `sudo tar -xzvf gdal-2.3.1.tar.gz` followed by `cd gdal-2.3.1`, `sudo ./configure`, `sudo make`, `sudo make install`. Then, reinstall `rgdal`. – nicola Aug 08 '18 at 15:05
  • First pass trying this hasn't worked (got error messages when trying to reinstall rgdal). What's the correct way of backing out in order to retry? – user1521655 Aug 08 '18 at 20:15
  • The first I error I am getting is `/usr/local/include/cpl_port.h:187:6: error: #error Must have C++11 or newer. # error Must have C++11 or newer. ^` – user1521655 Aug 08 '18 at 21:29
  • @nicola, are you willing/able to help me troubleshoot this? – user1521655 Aug 09 '18 at 17:30
  • I'd try the same as above with `gdal-2.2.4`. – nicola Aug 10 '18 at 04:38
  • While waiting to hear back, I tried adding the ubuntu-unstable repository to get gdal. According to Synaptic Package Manager, the version I have at this point is 2.2.2 (which is giving me different problems). I'll try installing the binaries as you suggest but I'd be curious to hear if you think it's a worthwhile endeavor. – user1521655 Aug 10 '18 at 15:17
  • Also doesn't work with gdal-2.2.4. `make install` ran kind of fast, so I'm not sure it succeeded. In any case, R is now giving me this error: `Error: package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/home/athorn/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs/rgdal.so': /home/athorn/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs/rgdal.so: undefined symbol: _ZN10OGRFeature16GetFieldAsStringEi Error: loading failed Execution halted ERROR: loading failed` – user1521655 Aug 10 '18 at 17:25

1 Answers1

0

What finally worked for me was trying to install an earlier version (v1.2-20) of rgdal that was compatible with gdal 1.11.3.

I was able to identify the correct version of rgdal using the documentation page here: https://www.rdocumentation.org/packages/rgdal/versions/1.2-20

Then I used the devtools package to install the correct version:

require(devtools)
install_version("rgdal", version="1.2-20")

This page has helpful information on installation of earlier versions of R packages: https://support.rstudio.com/hc/en-us/articles/219949047-Installing-older-versions-of-packages

I attempted installing more recent versions of gdal both from source and with my package manager but continued to get various errors when I got to the step of trying to install rgdal.

What I don't know is why I kept getting errors when trying to work with gdal upgrades.

user1521655
  • 486
  • 3
  • 17