Adapting to the recent changes in R spatial packages (sf, terra, PROJ library) (PROJ02R)
5th March 2025£280.00
Wednesday, April 13th, 2022
About This Course
R statistical software is becoming increasingly popular for spatial analysis and mapping. This is partially due to a large number of R packages devoted to applying various spatial methods. These packages, however, are being revised, updated, or even superseded to allow for better performance, simpler user interface, or expanded capabilities. Substantial recent changes in R spatial packages include developing the ‘sf’ package as a successor of ‘sp’, creation of `terra` as a successor of `raster`, and establishing the `stars` package. Additionally, all of these packages were affected by the recent major updates of the PROJ library. In this course, we will learn to use key packages for the analysis of spatial data, both vector (‘sf’) and raster (‘terra’), and see how they differ from their older counterparts, ‘sp’ and ‘raster’. Another important aspect of the course will be to understood spatial projections and coordinate systems, how the recent PROJ changes affect R users, and how to adjust to them.
By the end of the course, participants should:
- Understand the basic concepts behind spatial analysis ecosystem in R
- Know how packages such as sp/rgeos/rgdal/raster differ from their successors sf/terra/star
- Be able to switch from using packages such as sp/rgeos/rgdal/raster to sf/terra/stars
- Understood the basic concepts behind spatial projections, and how PROJ.7 differs from PROJ4
- Know how to deal with coordinate reference systems in R
- Have the confidence to switch from PROJ4 to PROJ7 (i.e., for instance, adjusting old scripts based on PROJ4)?
- Academics and post-graduate students working on projects related to spatial data
- Applied researchers and analysts in public, private or third-sector organizations who need the reproducibility, speed and flexibility of a command-line language such as R for spatial data analysis
- Current R users wanting to update your knowledge, including switch from using `sp` to `sf`, and from `raster` to `terra`
The course is designed for intermediate R users interested in understanding modern tools for spatial data analysis in R and R beginners who have prior experience with geographic data and other spatial software.
Last Up-Dated – 13:01:2022
Duration – Approx. 15 hours
ECT’s – Equal to 1 ECT’s
Language – English
The course will be a mixture of theoretical and practical. Each concept will be first described and explained, and next the attendees will exercise the topics using provided data sets.
Assumed quantitative knowledge
Understanding basic GIS concepts, such as spatial vector, spatial raster, coordinate reference systems would be beneficial, but is not necessary.
Assumed computer background
Attendees should already have experience with R and be able to read csv files, create simple plots, and manipulate data frames. The experience of using some basic R spatial packages, such as sp or raster would be beneficial.
However, if you do not have R experience but already use GIS software and have a strong understanding of geographic data types, and some programming experience, the course may also be appropriate for you.
Equipment and software requirements
A laptop computer with a working version of R or RStudio is required. R and RStudio are both available as free and open source software for PCs, Macs, and Linux computers. R may be downloaded by following the links here https://www.r-project.org/. RStudio may be downloaded by following the links here: https://www.rstudio.com/.
All the R packages that we will use in this course will be possible to download and install during the workshop itself as and when they are needed, and a full list of required packages will be made available to all attendees prior to the course.
A working webcam is desirable for enhanced interactivity during the live sessions, we encourage attendees to keep their cameras on during live zoom sessions.
Although not strictly required, using a large monitor or preferably even a second monitor will improve he learning experience
PLEASE READ – CANCELLATION POLICY
Cancellations are accepted up to 28 days before the course start date subject to a 25% cancellation fee. Cancellations later than this may be considered, contact email@example.com. Failure to attend will result in the full cost of the course being charged. In the unfortunate event that a course is cancelled due to unforeseen circumstances a full refund of the course fees will be credited.
If you are unsure about course suitability, please get in touch by email to find out more firstname.lastname@example.org
Day 1 – approx. 6 hours
Topic 1: Numerical programming with numpy. Although not part of Python’s official standard library, the numpy package is the part of the de facto standard library for any scientific and numerical programming. Here we will introduce numpy, especially numpy arrays and their built in functions (i.e. “methods”). Here, we will also consider how to speed up numpy code using the Numba just-in-time compiler.
Topic 2: Data processing with pandas. The pandas library provides means to represent and manipulate data frames. Like numpy, pandas can be see as part of the de facto standard library for data oriented uses of Python. Here, we will focus on data wrangling including selecting rows and columns by name and other criteria, applying functions to the selected data, aggregating the data. For this, we will use Pandas directly, and also helper packages like siuba.
Day 2 – approx. 6 hours
Topic 3: Data Visualization. Python provides many options for data visualization. The matplotlib library is a low level plotting library that allows for considerable control of the plot, albeit at the price of a considerable amount ofm low level code. Based on matplotlib, and providing a much higher level interface to the plot, is the seaborn library. This allows us to produce complex data visualizations with a minimal amount of code. Similar to seaborn is ggplot, which is a direct port of the widely used R based visualization library.
Topic 4: Statistical data analysis. In this section, we will describe how to perform widely used statistical analysis in Python. Here we will start with the statsmodels, which provides linear and generalized linear models as well as many other widely used statistical models. We will also cover rpy2, which is and interface from Python to R. This allows us to access all of the the power of R from within Python.
Topic 5: Symbolic mathematics. Symbolic mathematics systems, also known as computer algebra systems, allow us to algebraically manipulate and solve symbolic mathematical expression. In Python, the principal symbolic mathematics library is sympy. This allows us simplify mathematical expressions, compute derivatives, integrals, and limits, solve equations, algebraically manipulate matrices, and more.
Topic 6: Parallel processing. In this section, we will cover how to parallelize code to take advantage of multiple processors. While there are many ways to accomplish this in Python, here we will focus on the multiprocessing
Classes from 09:30 to 17:30
Overview of spatial analysis ecosystem in R
• available R packages for spatial analysis in R
• how do R packages represent spatial objects, and how are they connected with each other
• importance of using the more recent R spatial packages, such as ‘sf’ or ‘terra’
• main concepts behind map projections (geoids, datums, geographic/projected coordinates, types of projections, etc.)
• implementation of these concepts in the PROJ library (used by most R spatial packages)
• differences between PROJ.4 and its newer versions (e.g. PROJ.7)
Spatial vector data analysis in R
• spatial vector data processing & analysis in R
• read/write/and visualize spatial vector data
• differences between ‘sp’/’rgdal’/’rgeos’ and ‘sf’
• moving from ‘sp’ to ‘sf’ for spatial vector data processing & analysis
• spherical geometry: how this concept was recently implemented in sf, and what is an impact of this implementation
Classes from 09:30 to 17:30
Spatial raster data analysis in R
• spatial raster data processing & analysis in R
• read/write/and visualize spatial raster data
• differences between ‘raster’ and ‘stars’/’terra’
• moving from ‘raster’ to ‘terra’ for spatial raster data processing & analysis
• short overview of package ‘stars’
Coordinate reference systems
• how to switch from PROJ.4 to PROJ.7 in R
• open session: questions from the participants
Dr. Jakub Nowosad
- Introduction to spatial analysis of ecological data using R (ISPE)
- Making beautiful and effective maps in R (MAPR)
- Adapting to the recent changes in R spatial packages (sf, terra, PROJ library) (PROJ)
Jakub Nowosad is a computational geographer working at the intersection between geocomputation and the environmental sciences. His research is focused on developing and applying spatial methods to broaden understanding of processes and patterns in the environment. A vital part of his work is to create, collaborate, and improve geocomputational software. He is an active member of the #rspatial community and a co-author of the Geocomputation with R book.