我正在使用奇妙的新 sf 包运行两个多边形或其他 sf 对象的相交。它类似于:
a <- st_polygon(list(cbind(c(0,0,7.5,7.5,0),c(0,-1,-1,0,0))))
b <- st_polygon(list(cbind(c(0,1,2,3,4,5,6,7,7,0),c(1,0,.5,0,0,0.5,-0.5,-0.5,1,1))))
i <- st_intersection(a,b)
## GEOMETRYCOLLECTION(POINT(1 0), LINESTRING(4 0, 3 0), POLYGON((5.5 0, 7 0, 7 -0.5, 6 -0.5, 5.5 0)))
我如何只保留POLYGON
的GEOMETRYCOLLECTION
?在功能集合中选择不同的类型很容易,但我似乎无法在 sf 包中找到与 ST_CollectionExtract 等效的内容。