Session Ready
Exercise

Simplify the neighborhood boundaries

In sf you can use the st_simplify() function to reduce line and polygon complexity. In this exercise you will measure the size of objects before and after st_simplify() in two ways. You will compute the size in megabytes using the handy object_size() function in the pryr package and you will count the number of vertices -- the number of points required to delineate a line or polygon.

Instructions
100 XP

The packages sf and pryr are loaded in your workspace.

  • Review the geometry of the neighborhoods object.
  • Compute the object size for the neighborhoods object with object_size().
  • Compute the total number of vertices in the neighborhoods object by altering and applying the code in the exercise introduction -- st_cast(), sapply(), sum().
  • Use the st_simplify() function on neighborhoods and save the new object as neighborhood_simple. Use the preserveTopology = TRUE argument so that borders stay aligned and use dTolerance = 100 to set the amount of simplification allowed (this is in meters).
  • Compute the object size of neighborhoods_simple.
  • Compute the number of vertices in neighborhoods_simple.
  • Review the geometry of the neighborhoods_simple object.