Error in library(rgdal): there is no package called ‘rgdal’ Traceback:

When I run my Jupyter + IRKernel notebook with Binder everything works well, except I receive the following error with several CRAN packages (rgdal, rgeos, ggspatial, sf):

Error in library(rgdal): there is no package called ‘rgdal’ Traceback:

  1. library(rgdal)

otherwise, Binder with IRKernel and Jupyter is working fine.

Proof of support by CRAN (apparently I can only post 2 links as a new user)
https://cran.r-project.org/web/packages/rgdal/index.html

Any assistance in getting these to work with Binder would be appreciated (I’m new to github and binder) so the following repository may not be organized as it should

thanks for any help.
Derek.

I checked the MRAN to see if the rgdal package resided within it, which it does

https://cran.microsoft.com/snapshot/2019-04-15/web/packages/rgdal/index.html

I altered the runtime.txt file to force Binder to rebuild and then watched the build log.

I found this in the build log


* installing *source* package ‘rgdal’ ...
** package ‘rgdal’ successfully unpacked and MD5 sums checked
** using staged installation
configure: R_HOME: /usr/lib/R
configure: CC: gcc -std=gnu99
configure: CXX: g++ -std=gnu++11
configure: CXX11 is: g++, CXX11STD is: -std=gnu++11
configure: CXX is: g++ -std=gnu++11
configure: C++11 support available
configure: rgdal: 1.5-12
checking for /usr/bin/svnversion... yes
configure: svn revision: 1018
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘rgdal’
* removing ‘/srv/rlibs/rgdal’

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

When I run Jupyter with IRKernel on my macbook with
install.packages(“rgdal”)
library(rgdal)

the following is output, but I have full access to the rgdal package and everything works well.


Loading required package: sp

rgdal: version: 1.5-16, (SVN revision 1050)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 3.1.1, released 2020/06/22
Path to GDAL shared files: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/gdal
GDAL binary built with GEOS: TRUE 
Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
Path to PROJ shared files: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/proj
Linking to sp version:1.4-2
To mute warnings of possible GDAL/OSR exportToProj4() degradation,
use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.

Any suggestions on how to have the rgdal (and other packages in MRAN: sf, ggspatial, rgeos) run with Binder?

Thanks,
Derek.

According to the rgdal CRAN page:

The ‘GDAL’ and ‘PROJ’ libraries are external to the package, and, when installing the package from source, must be correctly installed first; it is important that ‘GDAL’ < 3 be matched with ‘PROJ’ < 6. From ‘rgdal’ 1.5-8, installed with to ‘GDAL’ >=3, ‘PROJ’ >=6 and ‘sp’ >= 1.4, coordinate reference systems use ‘WKT2_2019’ strings, not ‘PROJ’ strings. ‘Windows’ and ‘macOS’ binaries (including ‘GDAL’, ‘PROJ’ and their dependencies) are provided on ‘CRAN’.

https://cran.r-project.org/web/packages/rgdal/index.html

It sounds like you’ll need some external dependencies to compile the library.

An alternative might be to use a Conda environment.yml, if all the packages you require are also on conda-forge.

I think I got past that issue in my repo where I’m trying to run Tyler Morgan-Wall’s excellent rayshader package. I think I put related dependencies in apt.txt, such as libgdal-dev and libproj-dev. See here. You’ll come across the need to use apt.txt to get ubuntu to install some basic libraries fairly regularly. Search apt.txt on this page. And you’ll get a sense of that being a common usage pattern, and see here and consider it in the light of the quote manics pasted above from the rgdal CRAN page for more understanding of how the stuff rgdal needs is being set up in my example.

I think now I’m having problems with text rendering in the 3D images but that I got past rgdal issue, see here about then getting rgl output to render in Jupyter on Binder.

1 Like

Awesome! I really appreciate the assistance. I was playing around with the yml file creation (manually) and learned more about it following the suggestion so much appreciated. The apt.txt and example solved the problem!
Really appreciate the help.
Cheers,
Derek

2 Likes