block by nitaku 7025272

Precomputed Gosper regions

Full Screen

Same as Gosper regions, but computed offline and using TopoJSON. Follow the link for an introduction.

Despite their graphical similarities, this map is 49 times bigger than the previous one (it contains 117.649 hexagonal cells), making unfeasible to render it hex by hex.

The GeoJSON hexagons are created offline by running a python script (create_hexes.py). The script is not optimized, in fact it cannot handle a 7-order Gosper curve on my machine before running out of memory.

python create_hexes.py > hexes.json

The obtained file is converted into an ESRI Shapefile with ogr2ogr, and edited with OpenJump.

ogr2ogr -f "ESRI Shapefile" hexes.shp hexes.json

By using OpenJump, Hexes with the same class are merged into a different region for each class (merge/dissolve command). The resulting shapefile is converted back to GeoJSON with ogr2ogr, then to TopoJSON, then served to the client.

ogr2ogr -f geoJSON regions.json regions.shp
topojson --cartesian --no-quantization -p class -o regions.topo.json regions.json

The rendering of TopoJSON is described in this example, while the custom projection used to make the hexes appear regular is described here. Region borders are drawn by using TopoJSON’s mesh method (see the API reference and this example).

index.js

index.html

create_hexes.py

index.coffee

index.css

index.sass