I am trying to create a diagram for a hexagonal cartogram by dissolving internal polygons using the unionSpatialPolygonsor functions aggregate. I get homeless hexes that don't dissolve ... a dummy example to show the problem:
library(raster)
g <- getData(name = "GADM", country = "GBR", level = 2)
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)

library(maptools)
j <- unionSpatialPolygons(SpP = i, IDs = rep(1, length(i)))
par(mar = rep(0,4))
plot(j)
k <- aggregate(x = i)
par(mar = rep(0,4))
plot(k)

With the shapefile that I actually use (not for the UK), I get even more stray hexagons - some complete - some not.
source
share