我正在尝试使用unionSpatialPolygons
或aggregate
函数通过溶解内部多边形来为六边形地图制作大纲。我得到了一些不会溶解的杂散六边形...这是一个虚拟示例来展示问题:
# grab a dummy example shape file
library(raster)
g <- getData(name = "GADM", country = "GBR", level = 2)
# par(mar = rep(0,4))
# plot(g)
# create a hexagonal cartogram
# library(devtools)
# install_github("sassalley/hexmapr")
library(hexmapr)
h <- calculate_cell_size(shape = g, seed = 1,
shape_details = get_shape_details(g),
learning_rate = 0.03, grid_type = 'hexagonal')
i <- assign_polygons(shape = g, new_polygons = h)
par(mar = rep(0,4))
plot(i)
# dissolve the polygons to get coastline
library(maptools)
j <- unionSpatialPolygons(SpP = i, IDs = rep(1, length(i)))
par(mar = rep(0,4))
plot(j)
# same result with aggregate in the raster package
k <- aggregate(x = i)
par(mar = rep(0,4))
plot(k)
使用实际的shapefile(不是英国的)时,我会得到更多的杂散六边形 - 有些是完整的,有些则不是。
hexmapr
- 是否可以缩小六边形的大小并比较结果? - Stuart Allenj
中两个都是漏洞。 - guyabel