This code creates the desired outline of two combined shapes
square.df <- data.frame("x"=c(0,0,1,1,0),
"y"=c(0,1,1,0,0),
"ID"=rep("square",5))
square <- st_cast(st_combine(st_as_sf(square.df,coords = c("x", "y"))),"POLYGON")
plot(square)
triangle.df <- data.frame("x"=c(0,1,0.5,0),
"y"=c(1,1,1.5,1),
"ID"=rep("triangle",4))
triangle <- st_cast(st_combine(st_as_sf(triangle.df,coords = c("x", "y"))),"POLYGON")
plot(triangle)
plot(st_union(triangle,square))
But what if my data frame has multiple shapes, like this?
shapes.df <- rbind(square.df,triangle.df)
shapes <- st_cast(st_combine(st_as_sf(shapes.df,coords = c("x", "y"))),"POLYGON")
plot(shapes)
What sf object do I create and how do I get the outline of the combined polygons?
