【发布时间】:2021-09-26 11:56:58
【问题描述】:
此代码创建两个组合形状的所需轮廓
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))
但是如果我的数据框有多个形状,像这样呢?
shapes.df <- rbind(square.df,triangle.df)
shapes <- st_cast(st_combine(st_as_sf(shapes.df,coords = c("x", "y"))),"POLYGON")
plot(shapes)
我要创建什么 sf 对象以及如何获得组合多边形的轮廓?
【问题讨论】: