What the Hex? (a brief history of the hex)


 
What the Hex?


a brief history of the hex


I've been working with Tableau for approximately eight months and until just three weeks ago, I had never created a hex map.  Never.  Note one.  Nada.  However, once I started working with Tableau as a career, I quickly realized how important hex maps truly are.




This blog is generally intended for new “hex mappers” - those people like me that have seen them, know what they were, but have infrequently or never used them.  This blog, however, does provide a centralized location for a variety of hex map options and techniques and therefore may prove useful for more experienced users.




Very little of this blog post is original content.  It is meant to be a compilation of great posts from the past collected in one central location, with a bit of additional information and instruction from me to further compliment these great works.  




Okay, so you’ve heard of a hex map, but what are they and when should you use them versus a standard choropleth map (generally a standard filled map)?  




Let's first start with tile maps.  Tile maps are maps of an area using uniformly-sized shapes.  The tiles may be circles, squares, hexagons, etc.  For this article, I will speak only about the United States where hexagons are utilized to represent each state, but just about any shape could be used.  Hex maps are simply tile maps using hexagons.  




Hex maps have become the standard when visualizing data where the sizing of the geographical region is unimportant.  One of the major problems with a standard map is that most of the Western states are larger in area and give the impression of more visual weight, when in fact Eastern states are typically more populous.  For example, Montana has an area of 147,164 square miles and population of 1.05 million where New Jersey has one sixteenth the area of Montana (8,729 square miles), but nearly nine times the people (9.01 million).  When using a standard map, however, the sheer size of Montana causes it to carry far more “visual weight” than the more populous New Jersey.  A hex map removes that artificial nature of more weight being placed on larger states.





Standard Map





Hex Map

There are other disadvantages of standard maps as well.  First, the states in the Northeast are very difficult to see on a standard map because of their small geographical area.  Because they appear so small on the map, it can be difficult to select or hover over these states and nearly impossible to place any types of labels.  A hex map eliminates that issue because all states appear the same size.





Standard Map





Hex Map

Additionally, standard US maps create the “Alaska Effect”.  The Alaska Effect is where the lower 48 states are greatly minimized due to Alaska’s size on a map and its location far to the Northwest.  Hex maps eliminate this issue as well because all states are equivalent in size and Alaska and Hawaii are brought in closer to the lower 48 states.




Standard Map




Hex Map

Hex maps, however, are not always the best solution.  If you look closely at a hex map, the states are “generally” in the proper location, but it is far from perfect.  I live in Kentucky and work in Ohio, so let’s look at the tristate area of Ohio, Kentucky, and Indiana.  In the standard map, you can see the true geographical location of these three states in relationship to each other.  Kentucky is the Southernmost state with Indiana to the Northwest and Ohio to the Northeast.  However, this is very different on a hex map where Indiana and Ohio line up well, but Kentucky is shifted to the West. 




This occurs because the states of a hex map are all of equivalent size and it would simply be impossible for them to be placed in the exact same location relative to other states.  For this reason (and others), any time geography is an important part of the data, it is generally recommended that a standard map be utilized.  

For example, take the US Rivers and Streams viz from Jeff Shaffer.  This visualization looks at every stream and river within the United States.  It’s probably obvious to everyone that it would make no sense to try to use a hex map for this visualization as the actual geographical location is very important.  




You could also consider Jonni Walker’s Fires on Federal Land viz where he plots wild fires across the United States.  Again, geography is a crucial to this visualization and utilizing a hex map is illogical.  




Okay, now that we have a basic understanding of hex maps, how do we use them?

Over the years, numerous techniques have been introduced to create hex maps in different ways.  There are probably dozens of blogs and articles on the topic, but in this section, I will just be talking about a few of the breakthroughs.  


Although tile maps were already in existence, Brittany was one of the first to write about how to create them in Tableau.  In her blog, she talks about when she was first introduced to the tile map concept and how she built it in Tableau.  She basically plotted the points on a grid then used squares as the shape for each state.  Thanks for being a Tableau innovator!




Zen Master, Matt Chambers, read Brittany’s article and started looking into the technique as well.  This is when he found an article that discussed using hexagons for states.  The process was fairly similar to Brittany’s.  He used a custom hexagon shape and laid it out in a grid.  The biggest advantage is that he provided the custom shape and a spreadsheet with x, y coordinates within his article.  

Once you download the information, the process from there is pretty simple and very well-documented in this article.  One thing to note, you will need to take this spreadsheet and join or blendit with your data.  You will also need to change the hexcolumn and hexrow fields to dimensions.  

This method is very simple to use and in my opinion, the most straightforward.  It only contains one row of data for each state and it uses shapes at an x, y coordinate.  The only drawbacks are that it can be difficult to get the hexagons really close to one another (if that is what you wish) and you might have to size the shapes differently on your dashboard versus in your worksheet.  This causes you to have to jump back and forth from the worksheet to the dashboard to get sizing correct.




Matt Chambers’ Shapes



Rody Zakovich wanted to address the sizing issue and built on Matt’s work by creating a polygon data set.  Basically he plotted out points to draw the hexagons and “fill” them via polygons.  

In Rody’s blog post, he also provides an Excel worksheet and instructions.  His instructions are very clear, but I would add that under “Step 1: Plot the Polygon”, you will need to change “Point” to a dimension before putting it onto Path.

As you read through this, you will see that this perfectly addresses the sizing issue and it guarantees that your hexagons are a tight fit every time.  However, as Rody notes, you can’t directly add labels to polygons.  For that reason, he provides a very creative and simple workaround to use a dual axis and place labels on that axis.  The other drawback is that the data set must include one record for every intersection on each polygon.  That means that each state will have six records versus one. 



Rody Zakovich’s Polygons



Zen Master, Joshua Milligan, also built upon this great work.  He decided that he would create a spatial file.  In simple terms, a spatial file is a file that defines the geometries required to create a map.  

At the bottom of Josh’s post, you can download the spatial files.  They will be downloaded as a zip file.  Extract the contents onto your PC.  If this is your first time using a spatial file, like it was for me, then here is how you get started:

In Tableau, go to Data > New Data Source, and choose “Spatial file”.  



Browse to find the “HexStates.shp” shape file that you just extracted and select it.  This will be brought in as your data source.   




Go to the worksheet where you will be building your map and double-click on “Geometry” which will be listed as a measure.  This will create the hex map for you.  From there, just follow the remainder of the instructions from Joshua's fantastic blog post.  

This spatial file is a great option as it eliminates the issues with sizing, labeling, and the extra points required to draw the polygons.  However, you might prefer to have a bit more spacing between the hexagons.



Joshua Milligan’s Shape File



Luke Stanke was one person who preferred a bit more padding between the states, so he created a new shape file, built on Joshua's work, to create some spacing.   You can download the zip file using the link above.  You will connect and use it in the same exact manner that you did with Joshua’s file, except Luke’s is labeled as “HexStatesPadded.shp”. 

As you can see below, it looks the same as Joshua’s map, but with a bit of space between the hexagons.  




Luke Stanke’s Shape File with Padding


Sarah Battersby & Kent Marten's Shapefiles with US Territories

In Mar 2020, Sarah Battersby & Kent Marten constructed some new shapefiles that include the US territories of American Samoa, Guam, Northern Mariana Islands, Puerto Rico, and the US Virgin Islands.  


Sarah Battersby & Kent Marten's Shapefiles with US Territories


As a side note, the very handsome Ken Flerlage created a shapeshifting tile map where you can choose your shape, the size, the rotation, etc.  It’s quite interesting and I would suggest you check it out: Shapeshifting Tile Maps in Tableau.

So your question now is probably, when should I use one of these methods over the other?

Well, I have a very definitive answer for you…it depends.  I have utilized all of these methods and well, I like them all!  I like Matt Chambers’ method because it is probably the simplest, uses shapes (which most people have done before), and it only includes one record for each state.  But sizing can be a problem.  (As mentioned, I like this method and use it often.  To address the sizing issue where you need to jump between the worksheet and dashboard, I create a parameter with size ranging from 1 to 100, drop it on the size card, set a start and end point for the size, place it in the dashboard, then use Layout to shift it off the viewable area.  Then you can adjust it perfectly within the dashboard without jumping back and forth.  For full instructions, please see the my TC18 Tip Battle Round 2 video starting at 2:30 into the video).


In addition to the size of the shape, the aspect ratio (how wide and how tall your sheet is) will also need to be tweaked.  David Velleca has a really awesome trick to fix this quickly and easily so you never have to mess with it.  Read about it in his Fixing Aspect Ratios blog post (it's a super quick read).  


I love Rody’s polygon method as it removes the issue with sizing, but it creates additional records in your data set and you have to create a dual axis to label.

I like both shape file methods, but they do lose the flexibility that you have with Matt’s shapes to create spacing between the hexagons.

Basically, I believe that once you use each method a couple of times, you will realize that all of them are very easy.  Ultimately, I believe it comes down personal preference.  I personally like a little bit of space between the hexagons so I would tend to lean toward Matt’s shapes or Luke’s shape file.  However, many people I know prefer the hexagons to be a close fit and lean toward Rody’s polygons or Joshua’s shape file.  Ultimately I personally do not believe that one method is better than the other, it all comes down to what you think is the easiest and most visually pleasing.  I would strongly encourage you to read all of these blog posts and to try all of these techniques several times to determine what you like the best.

Before I close this out, I do want to say that it is simply amazing what our community is capable of.  One person has a great idea and builds it in Tableau.  Then several others come along and build upon it, give it their own twist and flair.  It’s simply amazing how this community inspires and helps each other improve.  Thanks to all that allowed me to reference their fantastic work.  

I hope you enjoyed the blog post.  If you have any questions, feel free to contact me at any time. 



Kevin Flerlage, November 9, 2018 

No comments:

Powered by Blogger.