使用sf包解散面要素

时间:2017-06-01 18:46:18

标签: r sf

Dissolve是作为sf方法here讨论的常见地理处理技术。

我正在尝试复制dissolve,因为它在ArcGIS中起作用。在ArcGIS中考虑两个组的县。

ArcGIS dissolve命令产生两个多边形,无论东半岛是否包含其他单独的多边形。像这样:

http://imgur.com/a/wAXBA

这是我想在sf中复制的功能,但是我不能如下所示。

nc <- st_read(system.file("shape/nc.shp", package="sf"))

#create two homogenous spatial groups
nc$group <- ifelse(nc$CNTY_ <= 1980,1,2)

#plot
ggplot() + geom_sf(data=nc, aes(fill = factor(group)))  

#dissolve
nc_dissolve <- nc %>% group_by(group) %>% summarize() 

#plot dissolved
ggplot() + geom_sf(data=nc_dissolve, aes(fill = factor(group)))

#Cartographically, it looks like we have two polygons, but there are 
#actually several more wrapped up as MULTIPOLYGONS. We can plot these.
t <- nc_dissolve %>% st_cast() %>% st_cast("POLYGON")
ggplot() + geom_sf(data=t, aes(fill=factor(row.names(t))))

注意半岛有多个多余的多边形。

如何在ArcGIS案例中只使用两个?非常感谢。

1 个答案:

答案 0 :(得分:4)

我不太熟悉ArcGIS如何定义多边形,但多边形的简单要素访问(ISO标准)规范是一个单个环,其中有零个或多个内环表示孔。这意味着在该规范下,如果你有主要土地+几个岛屿,你就没有一个多边形。要将这些表示为单个要素,相应的几何类型是多面。这意味着您的答案在nc_dissolve:它有两个功能。