Geometry Data Operations and Troubleshooting

Content for Monday, September 29, 2025

This session and the next one will focus on giving you more practice with manipulating the geometries of sf objects, calculating new variables based on those geometries, and converting sf objects to raster objects for use in terra. The primary goal of these two sessions is to refine your ability to manipulate spatial data and combine them into the databases we’ll need for conducting the analyeses in Part 3 of this course.

Readings

Bigger Picture

  • None Use this as an opportunity to revisit (or read for the first time) some of the previous material that discusses inferential challenges with spatial data.

Technical Details

  • The introductory vignette for the sf package has a lot of useful info on sf objects and conventions.

  • Section 2.2 on Vector Data and Sections 5.1-5.3 on Geographic Operations in Lovelace et al. (Lovelace et al. 2019) - for more details about vectors and geometric operations on vectors.

  • Section 3.1 and 3.2 of Spatial Data Science, a bookdown project by Edzer Pebesma and Roger Bivand (of the sf, sp, rgeos, and rgdal packages).

Objectives

By the end of today, you should be able to:

  • Use transformers to fix or modify geometries

  • Calculate new values using predicates.

  • Convert vector data to raster data

Slides

The slides for today’s lesson are available online as an HTML file. Use the buttons below to open the slides either as an interactive website or as a static PDF (for printing or storing for later). You can also click in the slides below and navigate through them with your left and right arrow keys.

View all slides in new window Download PDF of all slides

References

Lovelace, R., J. Nowosad, and J. Muenchow. 2019. Geocomputation with R. CRC Press.