How to Create Density Maps Using Hexbins in Tableau

11 Jul, 2016

Note: This is a guest post by Tableau enthusiast Matt Chambers.

Density maps are a great way to show concentration in an area. I recently saw a density map that visualized the concentration of tornados across the US without representing entire states.

I really liked this approach, and thinking through the steps, it occurred to me that this is dead simple to do in Tableau.

Let me show you how to create a density map in Tableau. Then we'll take it a step further to use hexbins as part of our density map.

How to Make Density Maps

All you really need to do is round the latitude and longitude.

1. Create calculated fields for the rounded latitude and longitude.

2. Drag the rounded latitude and longitude on to the Rows and Columns shelves. Make sure that both are continuous dimensions. Set the mark to square and set the size in the middle.

3. Drag the dimension you need to the color shelf and turn off gridlines. Hide both headers as well.

4. Finally, bring the worksheet into the dashboard and size appropriately. I used 1050 by 550 to get the sizing I liked.

How to Make Density Maps Using Hexbins

Now let’s try using hexbins for our density map. This is a bit more complex than rounding the lat/long but not much. Let's see how it's done.

1. Create a parameter called "ratio." This will let you control the binning. The higher the ratio, the more bins in the view.

2. Create the hexbins for latitude and longitude.

3. Drag Hexlong and Hexlat to Columns and Rows, respectively. Set your ratio to the binning level that you prefer. In this case, I used 2.5. Hide the headers as well.

4. Pull the worksheet into the dashboard and size appropriately. I used 1184 by 660 in this view.

That's all there is to it! Feel free to download the workbook and see how it is done. You can also post your questions in the comments below.

For more tips, ideas, and vizzes by Matt, check out his Tableau Public profile page and his blog, Sir Viz-a-Lot. You can also connect with him on Twitter @sirvizalot.

Comentarios

Submitted by Dan Murray (no verificado) on

Nice post.!

Submitted by david h. on

great intro example, thank you. Any more sophisticated examples available?

Submitted by Ashish C. on

Its very nice article and helpful. While following the steps I realised we can't make use of Lats(generated) and Longs(Generated) in the calculation. Thus we would need a separate Lats and Long columns as a part of data to achieve the same. If its not there you won't be able to achieve the first step.

Create the above all the calculation and drag them to dimensions and make them continuous in type. This are the basic problem I faced. I came to know all this after referring to the workbook link shared.

Thanks sir for sharing this awesome looking map.

Submitted by Alan E. on

Hi David,

You can find several posts on advanced hexbin techniques on my blog:
https://blog.databender.net/?s=hex

Cheers,
Alan

Submitted by Jaime F. on

Is it possible to achieve this with lets just say, using a geographic 'state' or 'zip code' dimension? Very cool example but unfortunately not all my data sets include Latitude and Longitude so achieving this just using a geographical dimension would be really neat!

Submitted by funny (no verificado) on

Amazing!

Thanks for sharing...I'll try to use it in my customer location analysis...