Session Ready
Exercise

Compute tree density by neighborhood (II)

We have the tree counts (from the previous exercise). In this exercise you will compute neighborhood areas, add them to the neighborhood sf object and then you'll join in the non-spatial tree counts data frame from the previous exercise.

Instructions
100 XP
  • Compute the areas of the neighborhoods with st_area() and wrap them in the unclass() function to remove the units. Save this object as areas.
  • Use mutate() to add the areas to your neighborhoods object. Call the new variable area.
  • left_join() the neighborhoods object (which should now have areas) and the tree_counts object that you calculated in the last exercise (preloaded).
  • Use mutate() with the given ifelse() code to replace NAs with 0.
  • Create a new column in neighborhoods called tree_density which is tree_cnt/area.