I have the following regions marked up over map

enter image description here

Each region has assicated statistical data.

The problem is that sizes of these regions are very different. Some regions are very big and another ones are very small.

Obvious idea is to hierarchically merge regions so that at each zoom we will approximately same size of aggregated regions.

Are there any algorithms for this task?

The problem is that regions are not adjacing ideally, they can slightly overlap or have gaps between them.

I tried the followng approach:

enter image description here

I considered a grid (the same grid as web merkator use for tiles) at given zoom and assigned each region to closest grid point (closest to each centroid). Then I grouped region by grid points and joined them at some zoom.

Unfortunately, this produced bad results. A lot of regions of strange shapes and with holes appeared.

What can be suggested as better approach?


The approach I would take is to merge them based on an underlying grid.

The best grid would be when your regions have some parent that they would fit in (e.g. neighbourhoods fit into districts, postal codes or census blocks). If you don't have them you can take a regular grid like hexagons or squares.

Your small polygons would be merged based on their centroid falling into one of the gridcells and for every zoomlevel you would use a more coarse grid.

Personally I would use postgis to solve this problem. Once you have the grid, it shouldn't be too much work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.