<< Back

Geospatial Heat Maps in Tableau via Alteryx

It is slightly ironic that while preparing last weeks post for the Show Me How series on Heat Maps in Tableau I was also preparing this, rather more complex post, on another form of heat mapping in Tableau – this time in the form of chloropleth maps.

Heat Mapping in this sense is straightforward in Tableau when in the form of Polygons datasets or points in just a few clicks, however it can be difficult to achieve any sense of further geographic analysis such as thematic gradients. In this post I want to explore I have worked around that problem using Alteryx, and show you how you can use a simple web application built in Alteryx to do the same.

Easy in Tableau

(stay tuned to our Show Me How series to find out how to produce these)

Heat Maps

Heat Maps

 

Hard / Impossible

The below thematic gradient map is difficult, especially where we only have point data. It shows areas of high concentration as a deep red, and low concetration as a blue – hence the heat map naming (hot -> cold). In this case the map below is actually showing temperature, but similar maps can be used to show population, etc.

sc_surf_data_14

 

Where something is hard or impossible in Tableau then I like to take it on as a challenge.

Alteryx to the Rescue

Many of our regular readers will be familiar with my love of Alteryx and what it allows me to do with Tableau that just wouldn’t be possible otherwise. This is definitely even more true in the geospatial world, Alteryx beats any other piece of BI / analytics software you care to name hands down when it comes to producing data for mapping.

If we have some points of data we want to convert into a heat map the process is actually quite complex, here are the steps:

1. Build a grid of data points, the size of the is dependent on the resolution of the map needed.

2. For each grid square (X):

a. Find the data points within that grid square X and sum their “heat” (e.g. sum their population)

b. For the neighbouring grid squares add their data points heat but reduced by a factor that is inversely proportional to the distance from grid square X.

Imagine doing this for many thousands of grid squares that might make up the UK or US and you can quickly see why it may be difficult and time consuming. I’ve flirted with the Table Calculations needed and it’s not straightforward, especially if you don’t have a pregenerated grid of data – which we don’t in most cases!

Thankfully a lot of this logic is already written into the “Heat Map” tool in Alteryx, however it only creates a 5 polygons containing points of similar “heat” for use as shape files or reports in Alteryx – useless from a Tableau point of view.

Customising Alteryx Tools

One of the many things I love about Alteryx is that many Alteryx Tools are in fact “macros” – meaning we can customise and edit those – and so we can edit the Heat Map tool for our purposes. That is exactly what I have done, the macro was well annotated and so I removed the pieces I didn’t need, mainly it was a case of simply removing the “Tile” tool and the latter part of the module. Then I saved a custom version – I love it that Alteryx make it that easy to steal and customise their experts work.

Then I imported my data and tested it, here was my test module:

Alteryx Heat Maps

 

The result for this test file in Tableau was a start but with more work I knew I could improve it. As you can see each point is replicated as a small dot in Tableau – like a pixel.

2014-12-02_16-58-53

 

A Real Use Case

To really test out this macro I wanted to put it through it’s paces with some real data – so I downloaded data from police.uk of every crime recorded in the UK from November last year. I then broke out the results by crime and used a “batch macro” in Alteryx to run the process multiple times, looking at weighted differences with regard population density (so it didn’t just show a map of population – as can happen when showing frequency of occurences) and produced the data for several categories – which was then combined into a single file and visualised in a Tableau workbook. Click to see the workbook on Tableau Public.

Police Data

 

Example Modules

You can download my macro and modules for the Test data here.

Build it yourself via this Free Alteryx Web Application

If you want to experience Alteryx yourself for 14 days you can using the free, easy to install trial but you can also experience the power of Alteryx via their web gallery. Just register and you can use this app I’ve put together to generate the data behind these maps yourself using your own data simply and easily. Give it a try, here, and you will find the app – fill in the details and run to get your tde of heat points ready to use in Tableau, use the workbook in the link above for details of how I then generated the viz in Tableau:

 

App

 

Enjoy creating your own heat maps, and please pass on any feedback via Twitter (@ChrisLuv) or in the comments below.

Chris Love

Nottingham, UK

11 thoughts on “Geospatial Heat Maps in Tableau via Alteryx

  1. Thanks Chris. Tried generating the Tableau heat map, but it throw some errors saying insufficient inputs. Can you tell me which file should be provided for each of the cases as indicated above? (Test input file, Latitude,Longitude and Heat).

    Regards,
    Venu Krishnan.

    1. Hi – you will need a file with points showing the items you wish to produce a heat map for, the file needs the latitiude and longitude of the instances, and the heat (i.e. intensisty). For my crime maps I used a file of postcodes with number of crimes at each postcode as heat. If you have no heat them use a column set to 1.

  2. Chris this is Awesome! I tried using the app that you provided, but I only received heat values of 0.005 and 0 based on my input values. my inputs ranged from 1-10 does the scale need to be larger?

    Thanks. matt

    1. It sounds like it, you will need to play with the settings it can be tricky. It’s hard to get it right for everyone. Better still download Alteryx and see what works for you.

  3. Hi Chris,
    I’ve downloaded your macro from the Tableau site you’ve linked in your blog post, however I’m unable to use it as I don’t have the “UkOutline.yxdb” file. Can you direct me to somewhere from which I can download it? Or is there another way round it?
    Thanks a lot,
    Josh

    1. I’m afraid you’ll have to source your own outline as one I used was copyrighted – perhaps just download one from online?

  4. Hi Chris — so I want to tweak the distances in Alteryx, but when I run your script (with the included TestLocations database), it says ‘The field ‘Point’ is not contained in the record’. What is the ‘point’ field and what should be contained within it?

    My guess is that the TestLocations db is not the file that we should actually be reading into your script, but I can’t find the one that will work. Can you pass that along or upload it to your DB?

    1. No I’d recommend you use your own file – you need latitude and longitude points and a measure of “volume” for heat – which can just be a “1”.

  5. Chris,

    Any tips for filling in the gaps between data points? Referring to the plot just before you get into “a real use case”. Having the areas without data show as the map background throws off the appearance of my heat map. Ideally the gaps would show the color corresponding to 0, or shade “colder” than the teal/green in your map. And when working with lat / long data, I find it hard to believe I would need every lat long in the map in my data set with a corresponding heat value of 0 in order to fill in the gaps between points in my original data set. Any workaround here? Thanks!!! Great stuff here!

  6. Hi there I just tried this and the column for heat just contains zeros. My file consisted of a list of 121 UK local authorities with their latitude and longitude and another column showing population. The resulting tde file just put a zero for each heat value.

    It would be really great to get this working even for an example data set as do a lot of mapping at work.

    I tried downloading your example data set but the download function wouldn’t work.

  7. This looks pretty interesting, and might help solve a project I’ve been working on recently.
    Do you know if this can be completed with the basic/desktop version of Alteryx, or would I have to upgrade to one of the additional packages?

Leave a Reply

Your email address will not be published. Required fields are marked *