Building this visualization
I've wanted to build a density dot map for a long time. So, moving forward with my Graphing Belarus series I finally made something similar. On the technical side, in addition to hexagonal binning, I've also played a bit with Canvas API — one more new thing for me.
1. Designing hex tile grid layout
First I looked for prior hexagon tile maps of Belarus. No luck to find any, I build a grid in Illustrator and played around with it until I was happy with the location of regions.
In addition, I have placed cities with special status separately, because sometimes it's nice to have this option for analysis.
You can download my version of the hex tile grid map of Belarus in a vector format for further manipulations.
Download SVG2. Generating hex tile grid map
Well, It's good to have a vector layout, but I wanted to build the tile map from scratch. This approach has obvious advantages: you can filter regions and leave only those you need for now, plot appropriate value to each tile, add interactivity.
I prepared a CSV file with the tile coordinates so that the map could be generated by the script. After Nadia Bremer's brilliant tutorials, I got some insight into the math and logic behind creating a hexagonal pattern and how to add boundaries between hexagons where I needed them. So after a couple of hours of despair and struggle I had a working code generating my hexagonal grid map.
3. Plotting dots pattern
Moving on, I was about to plot dot pattern for regions. But it was clear that this task was not for SVG.
That's when I took a break to get to know the Canvas API from MDN Docs. I found everything I needed there to create dotted patterns inside hexagonal clips.
(the visualization itself doesn't impress me much, but I'm happy with the process)
4. Adding a European context
Finally, I wondered if 46 people per square kilometer is a lot. So I decided to compare Belarus population density with other European countries.
The process with the map was almost the same as in the first stage, except that I found the ready-made hexagon tile grid map of Europe. It was the work by David Taylor I found in The Eurosearch Song Contest making-of article by Maarten Lambrechts. I made only some minor corrections by adding a few countries.
This time I've coded values with color and made a beeswarm plot, which also serves as a color legend. In order not to search for Belarus for a long time among other countries, I highlighted it in yellow.
Also to make mousehover effect smooth and nice, I added a top transparent interactive layer with a Voronoi diagram.
Notebooks Force-directed Beeswarm by Harry Stevens and Hover Voronoi by Mike Bostock were excellent reference for me at this stage.