I love hex maps! Especially for the United States, you can keep states in a basic geographic orientation, but eliminate the visual perception problems caused by the fact that some states are huge compared to others (and Alaska and Hawaii shift the scale when added).
But there are a few headaches that can occur when creating and using hex maps. Fortunately, there is a solution, which I believe offers the best of all worlds (and of course, I’ll include share download below!)…
Some background on Hex Maps in Tableau
Matt Chamber’s post on Hex Maps in Tableau inspired many with how easy it was to use custom shapes to create a hex map in Tableau. And he inspired me to use one (for my first time) in the 2017 Iron Viz finals:
But, as Rody Zakovich noted, it is impossible to precisely control the size of custom shapes in Tableau. And especially as you bring a view into a dashboard and adjust the size of the view, the size you had selected in the individual view probably isn’t right and you engage in a frustrating cycle of adjusting the size, returning to the dashboard, returning to the view and adjusting the size, …
So, Rody came up with a brilliant alternative: use polygons. In his blog post, Polygon Hex Map in Tableau, Rody demonstrates how to use a data set that defines a polygon hex shape for each state and then uses Tableau’s Polygon mark type to draw them. This approach eliminates the sizing issue because Tableau does a great job of precisely adjusting the rendering of polygons based on the size of the view.
But, polygons do have a couple of drawbacks:
- They are very difficult to label (Alan Eldrige has a great post on why and a potential work-around)
- The data set that defines them requires one record for every vertex of the polygon. So each state will have six records. This works well for blending, but joining is out of the question.
A Spatial File Alternative
One thing I love about the Tableau community is how we inspire each other! Brittany Fong comes up with tile maps. Matt uses the approach as one way of creating a hex map, it inspires me to use it and Rody to come up with another way. And then I see Rody’s approach and think, “That’s incredible! But what if…”
And as I thought about it, I realized that there is a feature in Tableau that might offer an alternative to polygons. And it’s a relatively new feature, only released in 10.2: Spatial File Support.
There is a lot you can do with spatial files that isn’t natively built in. I mean, sure you can render the current counties of the United States, but what about showing counties as they looked 100 or 200 years ago?
And what if you had a spatial file that rendered each state as a hexagon. So, I grabbed Rody’s data set and ran it through Alteryx to generate a shape file (.shp). Look at those amazing geospatial options:
I had to adjust a bit for the map projection (and no, I didn’t use some fancy Euclidean geometry, I used trial and error!) But in the end I had a spatial file that can be used in Tableau to render a hex map!
And it shows great promise:
- Labeling works beautifully!
- You can blend or join! (because the spatial file has the whole polygon in a single geometry field – so there’s only one row per state)
- It sizes perfectly as the view size changes.
Here’ a hex map of the Zillow home value index using a blend on State
Thanks to Tableau’s cross database join, I can also join shape files other data sources:
With an inner join, I might lose some states (Alaska and Hawaii do not exist in the Superstore demo data, so they won’t appear with an inner join, but a right join allow them to show up):
Sharing and Using the Spatial File
Do you want to use the spatial file yourself? Of course you do! And you’re in luck, because here are the spatial files (and the Alteryx work flow if you want to make your own adjustments!)
And a few notes on using it:
- Just double click the Geometry field to have Tableau generate the hex map!
- You’ll want to washout the map completely. I didn’t even try to match up the data from Matt and Rody with anything close to sensible latitude or longitude numbers, so you’ll see the hex map drawn over Africa (I like to think it’s close to Null Island). But, you won’t want to see the background map, so go to Map > Layers and wash it out:
- You’ll also want to go to Map > Options and remove all the interactivity that doesn’t really make sense with
And if this post inspires you to use hex maps or come up with a new approach of your own, I’d love to know!