Unable to install rgdal package in Rstudio

I am trying to install rgdal package in Rstudio.

OS: Ubuntu 16.04

Command: R --vanilla -e "install.packages('rgdal', repos = 'https://cran.rstudio.com')"

Expected Output:

rgdal should be installed.

Current Output:

Additional Information:

gdal-config --version command gives 2.3.0.

Any help is appreciated. Thanks!

Do you have this system dependencies installed?

sudo apt install libgdal1-dev libproj-dev libgeos-dev

@andresrcs Yes.

libgdal1-dev is already the newest version (1.11.3+dfsg-3build2).

libgeos-dev is already the newest version (3.5.0-1ubuntu2).

libproj-dev is already the newest version (4.9.2-2).

Maybe it's necessary to point out that you are using Anaconda3 and a conda environment, this usually brings this kind of problems, I hope some one else with a similar setup has a solution for this, other than using a regular r/rstudio setup.

You have 1.11.3. From the cran documentation of RGDAL:

for building from source: GDAL >= 1.11.4 and <= 2.5.0

It seems you don't have the correct version installed.You'll need to update maybe.

1 Like

is too old to have a package for newer versions of Gdal. In this case the package is not coming from Anaconda but the CRAN mirror and the package management in R (or Python for that matter) is notoriously bad for external dependencies - especially on older Linux. Anaconda uses a rather crude method to mitigate that but the package has to come from a conda channel (so you'd install it using conda install from command line. That would download the additional gdal shared library and inject the path to your LD_LIBRARY_PATH). I don't know if conda's support for R packages matches the one for Python's though. As I've said a few times on this forum, in my case we got tired of this problem of maintaining external dependencies by hand (about 900 R packages from CRAN, Bioconductor, Github,... to manage, keep up to date, etc.). See my old post which happens to deal with Gdal. Note that our approach is not for everybody - the learning curve is rather steep.

1 Like

@alexv Agreed. I understand what you mean and I have experienced similar issues with a couple of packages in the past. I already tried installing r-rgdal via conda like this: conda install -c conda-forge r-rgdal -n <env_name> but that results in either _r-mutex conflict or r-base conflict errors.

Additional Info: I am not installing r-base in conda. I am using mro-base since we need mro-base for certain performance reasons and existing functionalities.

You likely have a good reason for having the configuration you have.

Unfortunately this means your options are rather limited: it seems that the only one left is the manual install (good ol' ./configure, make, make install).

Gdal source files are at http://download.osgeo.org/gdal/CURRENT/ and the 2.5.0 version should keep you going for a while (roughly as long as the 16.04 ubuntu, give or take).

@aniketkul I know exactly what you mean - conda is brittle and unpredictable.
@jlacko That's exactly what I was doing in the beginning - compiling all the missing dependencies. Until I had do build gcc from scratch (The one in RHEL 6 wasn't fully c++11 compliant but some R package wanted that). Then I decided I'd had enough.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.