8

I am currently running some species distribution modelling and richness mapping in R on a linux cluster. In order to run my analyses I need to install rgdal so that the raster function in my modelling package works correctly. I have installed proj4 and gdal already. However when I attempt to install rgdal I get an error message:

checking for gdal-config... no
no

configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package 'rgdal'

This is the command I used to install rgdal package:

install.packages("rgdal", configure.args=c("--with-proj-include=/home/nikhail1/bin/proj-4.9.2/bin", "--with-proj-lib=/home/nikhail1/bin/proj-4.9,2/lib"))

However despite the gdal-config error, gdal seems to be installed onto my local system (the binary and library folders are present in the address to which I installed them). I also did not see any error messages during the gdal installation process. Why is this error occurring? How do I get R to recognize that this dependency is installed, or indeed if there is a problem how do I identify it? Most of the solutions I have found online are specific to Debian and Ubuntu systems which I am not using. I do not have authority to use sudo apt-get or yum commands. Are there any dependencies of gdal I am missing, as I have only installed proj 4.9.2?

I am new to the linux system, and the rgdal and gdal packages.

Thank you very much for you assistance

Kind Regards,

Nikhail

5 Answers5

7

Installing RGDAL in R on Linux

Run this command in R:

# install package from CRAN
# but specify the library director
# the download method
# and the configuration arguments
# to allow for source installs
install.packages( pkgs = "rgdal"
                    , lib = "./R_Packages"
                    , method = "curl"
                    , configure.args = c(
                                   "--with-gdal-config=/Library/Frameworks/GDAL.framework/Programs/gdal-config"
                                   , "--with-proj-include=/p/home/bin/proj4/include"
                                   , "--with-proj-lib=/p/home/bin/proj4/lib"
                                     ) 
      )

Answer comes from cross-referencing Errors installing rgdal on LINUX system? and Trouble installing rgdal.

Cristian E. Nuno
  • 2,822
  • 2
  • 19
  • 33
  • Thank you for your suggestion however the system I am on does not allow me to used the sudo apt-get command to install software as I am not on Ubuntu. Furthermore it appears I have installed both softwares (proj4 and gdal) as the folders are present in my repository. However I still get a gdal-config error, which is puzzling. – Nikhail Arumoogum Feb 14 '18 at 07:28
  • Thank you very much aspiringurbandatascientist. Your suggestion was not far off. I had to include the pathway to the gdal config file as well in the install.packages command – Nikhail Arumoogum Feb 16 '18 at 09:22
  • @NikhailArumoogum, that's awesome. Would you mind sharing the exact command you used? Once you do so, I'll update my answer to reflect the command that worked for you. – Cristian E. Nuno Feb 16 '18 at 14:19
  • 2
    `install.packages("rgdal", configure.args=c("--with-proj-include=/home/nikhail1/bin/proj-4.9.2/bin", "--with-proj-lib=/home/nikhail1/bin/proj-4.9,2/lib", "--with-gdal-config=home/nikhail1/bin/gdal/bin"))` – Nikhail Arumoogum Feb 21 '18 at 07:30
  • I doubt that this would succeed on any Linux system. The Frameworks mechanism of package deployment is a Mac invention. – IRTFM Apr 05 '23 at 23:13
3

I could fix a similar issue on a CentOS 7 system by first installing 'gdal' and 'proj' libraries via terminal-

sudo yum install gdal*
sudo yum install proj*

And then set configure arguments in install.packages command as follow-

install.packages( pkgs = "rgdal", 
                         configure.args = c("--with-proj=/bin", "--with-gdal=/bin"),
                         dependencies=TRUE)

Both the 'gdal' and 'proj' libraries were installed in root/bin folder in this situation. Although the error output printed that 'gdal-config not found', the config file wasn't required at the end.

2

So i have finally solved the issue by adding the directory of the gdal-config file in the install.packages command.

Thank you very much for your assistance, Nikhail

1

I followed these steps:

  1. I installed python via Anaconda;
  2. After I opened a Linux terminal and ran sudo apt install libmysqlclient-dev;
  3. Then I ran sudo apt-get install gdal-bin proj-bin libgdal-dev libproj-dev;
  4. Finally, I ran on R install.packages("rgdal");
Abdinardo Oliveira
  • 2,410
  • 1
  • 5
  • 12
  • I do not see why installing Anaconda or Python should be needed to solve the specific problem at hand. – IRTFM Apr 05 '23 at 23:15
0

For Arch based distros, just install gdal using pamac or Add/Remove Software before attempting any installation depending on rgdal in R.

NunonuN
  • 1
  • 2