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.

## Kommentare

Nice post.!

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

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.

Hi David,

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

Cheers,
Alan

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!

Amazing!

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

If you'd like to plot the hexbins with a map on the background, you can add "/[Ratio]" to the end of the formulas. This puts the bins back on the correct coordinates, while also maintaining the bin size used. For example:
HEXBINX([Longitude]*[Ratio],[Latitude]*[Ratio])/[Ratio]

I have implemented the solution Jeffrey gave to show the symbols on a map and it works great. The problem I am having now is that I can't see the underlying data when I click on a specific mark. The goal is to be able to click on the mark and then have a second sheet update with the record list that falls under that mark. Since I can't get the underlying data view to work, I can't update the other sheet. When I click to show underlying data, I get the location of the symbol and a count but the full data is just blank.

I finally solved my own problem. The issue seems to be that the data ends up as a float. As such hexbins that don't land on nice round numbers would fail to show underlying data. So I modified the formulas as such:
round(HEXBINX(round([Longitude]*[Ratio],6),round([Latitude]*[Ratio],6))/((100*[Ratio])/100),6)
round(HEXBINY(round([Longitude]*[Ratio],6),round([Latitude]*[Ratio],6))/[Ratio],6)

Knocking off digits longer than 6 after the decimal allowed it to work. Then I made a sheet with the rows of the records and added it to my dashboard and then used the map as a filter for that sheet so when I click a bin, I see a list of the records right in the dashboard.