I have a polygon sf object of 125 unique polygons (representing different areas scattered throughout a US state). None of the polygons share a border. I also have a 30m hillshaded digital elevation model raster image of the state, which covers the area of the polygons (and then some). I want to use the terrain function from the raster package to calculate the unique slope and aspect for each polygon. My end product would be having the polygon sf object with two new columns, slope and aspect, so each polygon would have its slope and aspect.
I have used the terrain function on the original, state-wide raster image and a masked raster image of just the polygon areas, which returns the min and max slope and aspects for the whole raster image.
Beyond that, I am pretty lost on how to get the slope and aspect calculated for each unique polygon's area, and then get that data into the polygon sf object. If anyone has any advice I'd be happy to hear it.
Thank you!