Europe geo to square tiles animation with geo2rect
This example animates a geographic map of Europe into a square tile grid, using the geo2rect library to morph each country’s polygon into a rectangle positioned at a custom grid location. The visualization loads Natural Earth-derived GeoJSON, simplifies multipolygons and holes, and uses D3 v4 with SVG paths and a Mercator projection. Clicking the toggle button switches between the original geo layout and the tiled arrangement, with a 2000-millisecond transition animating the transformation. The grid positions are manually defined in a configuration object, and the code relies on geo2rect’s internal computation of closest corner points to map each shape.
AI-generated descriptionThe code I used to animate the geographic map of Europe to a square tile map in The Eurosearch Song Contest. It uses the great geo2rect by Sebastian Meier.
This map is basically a clone of one of Sebastian's examples. I created the geojson from Natural Earth data, selected the countries I needed (the Eurovision participants) in QGIS and simplified the geometries with mapshaper. Laying out the tile grid was a nice puzzle (yes, looking at you, Balkans).
Some remarks:
- geo2rect filters out holes and only keeps the biggest polygon of multipolygons (tough luck, Northern Ireland and Northern Cyprus...)
- I filtered out some smaller European countries and islands from the geojson, like Andorra and Liechtenstein.
- I kept Australia in, as it participated in the Eurovision Song Contest. You can see it flying in from the bottom right corner.
- I had to override the scale and center of the map in geo2rect.js. geo2rect calculates these from the geometries, but because Russia is so big and Australia is in there, I had to zoom in on Europe manually.
You can read the whole making-of of the Eurosearch Song Contest on my site.
forked from <a href='http://bl.ocks.org/maartenzam/'>maartenzam</a>'s block: <a href='http://bl.ocks.org/maartenzam/ec11de22bc8e5608a98f207f1c09bdb6'>Europe geo to square tiles animation with geo2rect</a>
forked from <a href='http://bl.ocks.org/axbazin/'>axbazin</a>'s block: <a href='http://bl.ocks.org/axbazin/780f8a4dd448765957358fd8f514303c'>Europe geo to square tiles animation with geo2rect</a>