# Materials

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)

# Slides

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

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

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:

# Projections and coordinate reference systems

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

# Other resources

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:

1. 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.↩︎