Session Ready
Exercise

Create a map using ggplot2

The geom_sf() function operates like any other layer in ggplot2 where you can link variables to aesthetics on the plot through the aes() function. In a mapping context this might mean, for example, creating a choropleth map by color coding the polygons based on a variable. If you leave off the aesthetic mapping geom_sf() will map the geometry alone.

devtools::install_github("tidyverse/ggplot2")
Instructions
100 XP

ggplot2 is loaded in your workspace and the CRS for both objects have been transformed so they match. Note that there is no EPSG code, just a proj4string, for this CRS and this is fine.

  • Use ggplot() and geom_sf() to create a map of tree_density using the default colors.
  • Use ggplot() and geom_sf() to create a map of avg_canopy using the default colors.
  • Alter the map of tree_density by changing the colors with scale_fill_gradient(). We have provided the hex codes (a # followed by numbers) for shades of green.
  • Alter the map of avg_canopy by changing the colors with scale_fill_gradient(). We have provided the hex codes (a # followed by numbers) for shades of green.