Session Ready
Exercise

Limit rasters to focus areas

Mask and crop are similar operations that allow you to limit your raster to a specific area of interest. With mask() you essentially place your area of interest on top of the raster and any raster cells outside of the boundary are assigned NA values. A reminder that currently the raster package does not support sf objects so they will need to be converted to Spatial objects with, for example, as(input, "Spatial").

Instructions
100 XP
  • Project the preloaded parks object to match the canopy raster with st_transform() and crs(). Assign this to parks_cp.
  • Compute the area of the parks with st_area() and save this object as areas.
  • Filter the parks to only those above 30000 square meters with the filter() function. You will need to wrap areas in unclass(). Save as parks_big.
  • Review the plot of canopy raster.
  • Plot the geometry of the parks_big.
  • Convert the parks_big object to the Spatial class (the class from the package sp) with as(input, "Spatial") and save this as parks_sp.
  • Mask the canopy layer with parks_sp and save as canopy_mask. This may take a couple of seconds.
  • Review the plot of canopy_mask.