I've long had GDAL, proj, etc. installed and working fine for various other related software (e.g., QGIS). Unfortunately, every time R gets updated it tends to lose links to previously installed R libraries. I'm used to this, just a little annoyed, and I try to re-install rgdal. However, it doesn't work this time.

> install.packages('rgdal')
Installing package into ‘/home/arthur/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rgdal_1.4-3.tar.gz'
Content type 'application/x-gzip' length 1687331 bytes (1.6 MB)
downloaded 1.6 MB

* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
configure: R_HOME: /usr/lib/R
configure: CC: gcc -std=gnu99
configure: CXX: g++
configure: C++11 support available
configure: rgdal: 1.4-3
checking for /usr/bin/svnversion... yes
configure: svn revision: 828
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.2.3
checking GDAL version >= 1.11.4... yes
checking GDAL version <= 2.5.0... yes
checking gdal: linking with --libs only... yes
checking GDAL: gdal-config data directory readable... no
checking GDAL: GDAL_DATA data directory readable... configure: error: GDAL data directory not found.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/home/arthur/R/x86_64-pc-linux-gnu-library/3.5/rgdal’

The downloaded source packages are in
Warning message:
In install.packages("rgdal") :
  installation of package ‘rgdal’ had non-zero exit status

Searches online aren't very helpful because most users reporting this kind of error actually didn't have GDAL or a related dependency installed. This problem cropped up on Ubuntu GNU/Linux 18.04 with GDAL version 2.2.3 and R version 3.5.2.


Luckily, I was able to figure this out. It is necessary to set the GDAL_DATA directory in the same terminal session, open R, then install rgdal.

Set the GDAL_DATA environmental variable:


Location will vary by system; another good guess is /usr/local/share/gdal/. You should use find to locate your directory.

Then, in the same session, open R at the command line with R and install rgdal:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.