Session Ready
Exercise

Compute polygon centroids

Similar to buffering, computing polygon centroids is a bedrock geoprocessing task used to assign values and even to help with labeling maps. The function for this in sf is st_centroid().

Also similar to buffering, centroid calculations should generally be performed on data with a projected coordinate reference system.

Instructions
100 XP
  • Read in the neighborhoods shapefile ("neighborhoods.shp").
  • Project/transform the neighborhoods shapefile and use CRS number 32618 as the target CRS, this is the code for the CRS of the manhattan image.
  • Compute the centroids with st_centroid() and store as an object named centroids. Only one argument is required.
  • Plot the geometry of neighborhoods_tf object with the centroids on top. This requires two calls to plot() run together. The second will need add = TRUE.