aheiss@gsu.edu

All the materials for today’s workshop are accessible in this RStudio.cloud workspace. You’ll be able to run R and RStudio directly from your browser and you don’t need to install anything on your computer.

You can also download a `.zip`

file of all the materials here and run all the code on your own computer (after installing R and RStudio and these packages: `tidyverse, sf, tigris, tidygeocoder`

)

Here are the slides for the different sections of today’s workshop:

- 0: Introduction (PDF)
- 1: Maps, truth, and data (PDF)
- 2a: Getting started with R and RStudio (PDF)
- 2b: Visualize data with ggplot2 (PDF)
- 2c: Transform data with dplyr (PDF)
- 3: GIS in R with sf (PDF)

I’ve designed today’s workshop to be accessible even if you’ve never used R before, but if you haven’t, you might want to revisit some of the GPL workshops from last summer on R and the tidyverse and data visualization.

Shapefiles are special types of data that include information about geography, such as points (latitude, longitude), paths (a bunch of connected latitudes and longitudes) and areas (a bunch of connected latitudes and longitudes that form a complete shape). Nowadays, most government agencies provide shapefiles for their jurisdictions. For global mapping data, you can use the Natural Earth project. Here are some common places to find shapefiles:

- Natural Earth
- US Census Bureau
- Georgia GIS Clearinghouse (requires a free account; the interface is
*incredibly*clunky) - Atlanta Regional Council
- Fulton County GIS Portal
- City of Atlanta, Department of City Planning

Projections matter a lot for maps. For instance, play around with these two websites:

You can convert your geographic data between different coordinate systems (or projections)^{1} fairly easily with **sf**. You can use `coord_sf(crs = st_crs("XXXX"))`

to convert coordinate reference systems (CRS) as you plot, or use `st_transform()`

to convert data frames to a different CRS.

There are standard indexes of more than 4,000 of these projections (!!!) at epsg.io.

**Super important**: When using these projections with `geom_sf()`

, you need to specify both the projection catalog (ESRI or EPSG; see here for the difference) and the projection number, separated by a colon (e.g. “`ESRI:54030`

”). Fortunately epsg.io makes this super easy: go to the epsg.io page for the projection you want to use and the page title will have the correct name.

Here are some common ones:

- ESRI:54002: Equidistant cylindrical projection for the world
- EPSG:3395: Mercator projection for the world
- ESRI:54008: Sinusoidal projection for the world
- ESRI:54009: Mollweide projection for the world
- ESRI:54030: Robinson projection for the world (This is my favorite world projection.)
- EPSG:4326: WGS 84: DOD GPS coordinates (standard −180 to 180 system)
- EPSG:4269: NAD 83: Relatively common projection for North America
- ESRI:102003: Albers projection specifically for the contiguous United States

Alternatively, instead of using these index numbers, you can use any of the names listed here, such as:

`"+proj=merc"`

: Mercator`"+proj=robin"`

: Robinson`"+proj=moll"`

: Mollweide`"+proj=aeqd"`

: Azimuthal Equidistant`"+proj=cass"`

: Cassini-Soldner

There are lots of tutorials and free textbooks online about how to use the **sf** package to do GIS stuff with R. Here are some really helpful and interesting ones:

- “Drawing beautiful maps programmatically with R, sf and ggplot2”: This shows cool things like how to add a compass sign and a scale bar
- “Designing Map Cutouts with {sf} and {ggplot2}”: This person made some fancy wall art using shapefiles and
**sf** *Geocomputation with R*: A complete free textbook for using**sf**with R; shows more complex GIS calculations*An Introduction to Spatial Analysis and Mapping*: All the code for another textbook for using**sf**with R; shows more complex GIS calculations- GSU PMAP 8921: Data Visualization with R: Space: This is a lecture and complete example video and code from my online GSU course on data visualization.

TECHNICALLY coordinate systems and projection systems are different things, but I’m not a geographer and I don’t care that much about the nuance.↩︎