Post

For the German election we wanted to use a cartogram of German election districts but didn't find anything good, so we created our own. Here's a little nerd thread how the final algorithm worked 🤓 🧵 #gis #cartogram #election #datavis #cartography

Before running the network layout simulation on this, we marked all the outer districts as fixed. This allows the final layout to stay "in shape" of the country as a whole, which is important for readers to recognize their country. We used the TopoJSON arcs to automatically find these districts.

1 repost56 likes

Some of these fixed districts turned out to be too close to each other, so we defined a few exceptions for border districts we want to be free, and also a few custom positions that prevent the nodes to "leave" the country.

To compute the final layout we use a force simulation with 3 forces: one of them keeps neighboring districts together while another pushes districts away from each other if they are too close. Coloring the nodes helped to identify problems during the process.

Of course, no cartogram comes without distortion. The western states like North-Rhine-Westphalia are heavily populated and push the lesser populated districts to the East. But the final layout worked well during election night, I think.