【发布时间】:2019-03-10 07:36:23
【问题描述】:
有没有办法用 sf 包从 R 中的多边形中删除孔?我也会对包含其他软件包的解决方案感兴趣。
这是一个带有两个孔的多边形示例。
library(sf)
outer = matrix(c(0,0,10,0,10,10,0,10,0,0),ncol=2, byrow=TRUE)
hole1 = matrix(c(1,1,1,2,2,2,2,1,1,1),ncol=2, byrow=TRUE)
hole2 = matrix(c(5,5,5,6,6,6,6,5,5,5),ncol=2, byrow=TRUE)
pts = list(outer, hole1, hole2)
(pl1 = st_polygon(pts))
# POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1),(5 5, 5 6, 6 6, 6 5, 5 5))
下图:
plot(pl1, col="red")
【问题讨论】:
-
好的,谢谢。现在,
sf有类似的解决方案吗?