Chapter 3 Map

R has had tools for mapping spatial data for a long time, but some of these tools could take a while to learn if you were just used to basic plotting in R. Recently, some packages have been developed for mapping spatial data that fit within the ggplot framework, so they allow you to take what you’ve learned about creating non-geographical plots and apply them to create maps.

The sf package (Pebesma 2019Pebesma, Edzer. 2019. Sf: Simple Features for R. is a fantastic new(-ish) package for mapping in R. The “Tidy” section of this handout describes how the tidyverse framework is based on a “tidy” data format. The “tidy” data framework is also convenient for cleaning, merging, and manipulating data before plotting or modeling it. The sf package allows you to read in and work with geographical data in a tidy format. It turns out that this is very powerful, as you can learn how to do a few things well (plotting [see the “Plot” section] and working with data [see the “Tidy” section and its “Learn More” references]), and then apply these tools in the same way, whether you’re working with geographical or non-geographical data.