有没有一种方法可以消除使用多边形之间的小“条” R
?理想的解决方案将创建一个新SpatialPolygonsDataFrame
的多边形之间共享边界重合的地方。我对使用R
而不是ArcMap或QGIS 的解决方案特别感兴趣。
我也想听听有关为什么首先存在这些差距的解释。
这是我正在处理的空间数据的可重现示例:
library(rgdal)
library(sp)
library(tigris)
library(magrittr)
library(leaflet)
library(gplots)
# This project will use WGS 84 projected coordinate system
crs_proj <- CRS("+init=epsg:4326")
# These are the FIPS codes of the specific block groups in my study area
sel <- c("530330079005", "530330079001", "530330079004",
"530330085002", "530330085003", "530330086003",
"530330087003", "530330085001", "530330090001",
"530330091001", "530330091002", "530330092001",
"530330092002", "530330086001", "530330090002",
"530330086002", "530330079003", "530330079002",
"530330087002", "530330087001")
# Create polygons
polygons <- tigris::block_groups(state = "WA",county = "King") %>%
.[.@data$GEOID %in% sel,] %>%
spTransform(CRSobj = crs_proj)
# Map the result
leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(data = polygons,
stroke = F,
fillColor = col2hex("red"), fillOpacity = 1)
如您在上面的屏幕截图中所见,人口普查区块组多边形之间存在很小的间隙。这些间隙的这些位置根据缩放级别而有所不同,但是始终有一些间隙可见。
谁能推荐一个R
功能(或多个功能的组合)来以编程方式调整多边形以消除这些间隙?