I have a dataframe containing the coordinates of a set of polygons. This is how I would convert it to a spatialPolygons (package sp)
my.df <- data.frame(
Plot = c("A", "A", "A", "A", "A", "B", "B", "B", "B", "B"),
Corner = c("SW", "NW", "NE", "SE", "SW2", "SW", "NW", "NE", "SE", "SW2"),
Easting = c(511830, 512230, 512230, 511830, 511830, 511730, 512130, 512130, 511730, 511730),
Northing = c(7550903, 7550903, 7550503, 7550503, 7550903, 7550803, 7550803, 7550403, 7550403, 7550803))
utm18 <- CRS("+init=EPSG:26918")
my.sp <- df_to_SpatialPolygons(my.df, keys = "Plot", coords = c("Easting", "Northing"), utm18)
plot(my.sp)
How can I create an sf object (package sf) containing these two polygons directly from my.df?
Edit: My question is partially answered in this question, but their response only illustrates how to create a single polygon. How do I create multiple polygons?
Convert sequence of longitude and latitude to polygon via sf in R