Create hexmaps from geoJSON boundary files using an energy minimisation technique.
- Load a GeoJSON file and find the centroid of each polygon (we use Leaflet to help with).
- Create a grid of hexes, and place the collection of centroids on top of it.
- In turn, the nearest unassigned hex to each centroid is highlighted. An "energy cost" is calculated which penalises the distance between each centroid and its corresponding hex.
- Slightly reduce the scale of the collection of centroids and repeat step 3.
- Repeat until the scale is tiny and then select the zoom at which.
- We use Raphael.js to visualise all of this.
- We output HexJSON of the final configuration.
- The HexJSON is visualised using a HexJSON to HTML library.