Hex map is quite popular for representing US geography in Tableau. Some asked how to create one for their own country or region. So here we will show the basic steps.

Hex map is a simplified way to represent a real map. It's an approximation. Some would say, even the "true map" is just an approximate representation of the reality, not the exact one.

Tableau Zen Master Matt Chambers proposed a Hex Map approach to US map. It looks great and seems better than tiled maps, because it tightly weaves all the State pieces together, thus looks a lot better. In a hex map, one state is neighbor to 6 states while in a tiled map, one state is neighboring 4 states.

But the hexagons are not close enough when using Tableau shapes. There left some gaps between states, especially when we resize the map.

Zen Master Rody Zakovich created a polygon based hex map, which is easy to resize while keeping the pieces always together. Zen Master Joshua Mulligan proposed a Spatial File based approach which also fixes the resize problem. But it is made with Alteryx which is a luxury not everyone can afford.

I made some improvement on Rody's polygon approach by eliminating the extra 51 rows for labeling.

Here I will show you the steps of creating a polygon-based hex map.

1. Understanding the data set
Load the hex map file (credit to Matt Chambers) to Tableau. It has got 51 rows of data. Each row contains one US state and its coordinates. For those who want to create your own Hex map, you need to create a data set like the one by Matt.

Horizontally between two neighboring data points, the distance is 2. Between two row of States, there is a horizontal shift of 1.

Vertically, the distance is 3.

2.Calculating the vertices of each hexagon
The above data set actually defines the center of each hexagon.

For a polygon-based hexagon, we need to define 6 vertices. Then a polygon is defined. For each of the 6 vertices, there will be one corresponding data row.

Given the horizontal and vertical distances, we derive the distances between each vertex and the center. Note that the horizontal and the vertical scales of a hexagon is different. So the calculation of the two coordinates are different too in scale.

//X is the horizontal coordinate of the center of a hexagon.
[X]
+COS(-[Pi]/2+[Table Index]*[Pi]/3)*2/SQRT(3)

//Y is the vertical coordinate of the center of a hexagon.
[Y]
+SIN(-[Pi]/2+[Table Index]*[Pi]/3)*2
3.Labeling
Labeling tiled map or hex map has not been a big issue but there lacked a systematic approach to it.

In our design, we used AVG() to the coordinates. When using dual axis for the labeling, we removed the vertex dimension and the AVG() of vertices will point to the center of the hexagon, thus very well positioned for labeling.

Voila, those are the main steps to creating a scalable and tightly woven hex map for any region on the earth. View the video for more details. Download the workbook here. You can use the map to blend with other data sets as you wish.
0

Add a comment

Blog Archive
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.