1  Why R for geosciences?

1.1 What about other programming languages?

This is not a competition and actually learning one programming language might be a good gateway to learning a second one.

Choosing a programming language is more about what your feel more comfortable with, what tool is good for the job or what the rest of your team is using.

Here are other courses on Python and Julia at EGU24:

Data science programming languages courses at EGU24
Mon. 15.04. 19:00 - 20:00
Introduction to Geospatial Raster and Vector Data with Python
Wed. 17.04. 08:30 - 10L15
Introduction to Julia for geoscience
Thu. 18.04. 16:15 - 18:00
Introduction to Python for Earth System Sciences

1.2 R-spatial ecosystem

R-Spatial can be loosely defined as the ecosystem of code, projects and people using R for working with and adding value to spatial data.1

The R-spatial organization attempts to harmonise packages for spatial analysis in R, with a large number of R packages depending on {sf}, the core package for spatial data handling.

A good overview of the available spatial libraries can be found in the CRAN Task View: Analysis of Spatial Data

R-spatial ecosystem from Pebesma and Bivand (2023a)

1.3 Rspatial counterpart

Not to be confused with R-spatial, the Rspatial resources include a different way to handle geospatial data in R. The main package {terra} provides classes and methods to represent raster and vector objects. It works well on large data sets and is a fast implementation mainly because it is written directly in C++. This means that, for example, a Python module could also be built on top of this library2. {terra} is based on C++ modules like gdal, geos and ncdf and builds it’s own spat module on C++ that interacts with R via the Rcpp module3.

{terra} set-up from R. Hijmans (2020)

  1. https://www.osgeo.org/projects/r-spatial/↩︎

  2. In theory, but has not been implemented yet↩︎

  3. Even though a C++ implementation is in many cases faster, it is harder to understand, debug or modify.↩︎