BwUniCluster2.0/Software/R/Rgdal: Difference between revisions
m (M Janczyk moved page Rgdal to BwUniCluster2.0/Software/R/Rgdal) |
|
(No difference)
|
Revision as of 11:53, 14 March 2023
General information
Installation of rgdal and rgeos allows to use the following tools for handling spatial structures in R
- the 'Geospatial' Data Abstraction Library GDAL
- Projection/transformation operations from the PROJ library
- Interface to the open source Geometry Engine GEOS
Installation
Please enter the following code, presented in the boxes below, directly into your shell/command line on bwUniCluster.
Install external programs
First, we download the sources of GDAL, PROJ, GEOS and install the three programs.
We will gather them in a folder src, unpack there and then compile.
We strongly recommend to use a interactive session with multiple cores.
salloc -n 4 -t 30 -p dev_single
First, provide the source directory (if not yet existing)
mkdir -p ~/src cd ~/src
Then, download and install PROJ
PROJ_VER=6.3.2 wget http://download.osgeo.org/proj/proj-$PROJ_VER.tar.gz tar xf proj-$PROJ_VER.tar.gz cd proj-$PROJ_VER ./configure --prefix=$HOME/sw/R make -j 8 make install cd ..
Then, install gdal
GDAL_VER=3.4.1 wget http://download.osgeo.org/gdal/$GDAL_VER/gdal-$GDAL_VER.tar.gz tar xf gdal-$GDAL_VER.tar.gz cd gdal-$GDAL_VER ./configure --prefix=$HOME/sw/R --with-proj=$HOME/sw/R make -j 8 make install cd ..
Finally, install GEOS
GEOS_VER=3.9.2 wget http://download.osgeo.org/geos/geos-$GEOS_VER.tar.bz2 tar xf geos-$GEOS_VER.tar.bz2 cd geos-$GEOS_VER ./configure --prefix=$HOME/sw/R make -j 8 make install cd ..
Installing the R packages
In order to install the two R packages, we need R to understand where we installed the 3 underlying programs, so we export the necessary paths.
export LD_LIBRARY_PATH=$HOME/sw/R/lib:$LD_LIBRARY_PATH export PATH=$PATH:$HOME/sw/R/bin export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib/pkgconfig export GDAL_DATA=$HOME/sw/R/share/gdal
Additionally, the R package installation features compilation of built-in C++ code, for which we specify compilation options ('compiler flags')
export CFLAGS=-I$HOME/sw/R/include export CXX="icpc -std=c++11"
Now, we install rgdal and rgeos from within R
module load math/R/4.1.2 R -q > install.packages("rgdal") > install.packages("rgeos") > library("rgdal") > library("rgeos")
Preparations to use the rgdal/rgeos packages
Since rgdal and rgeos depend on the external programs we installed, several environment variables have to be set before using the packages to allow R to address these programs.
We recommend to add the export commands
export LD_LIBRARY_PATH=$HOME/sw/R/lib:$LD_LIBRARY_PATH export PATH=$PATH:$HOME/sw/R/bin export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/sw/R/lib/pkgconfig export GDAL_DATA=$HOME/sw/R/share/gdal
to your batch job scripts that use rgdal and rgeos or to run them directly in the command line if you use an interactive session.