Using Shape Files for Boundaries in Tableau

[With the release of Tableau 10.2 we now natively support shapefiles as a data source. This approach is no longer required. If you are using a version prior to 10.2 I strongly recommend you upgrade as the native support is much faster and easier to work with than this approach.]

[Once again, I’d like to recognise another person for helping make great content for this blog. This time it’s Susan Day, consultant extraordinaire at MIP (a wonderful partner here in Australia) who took my original workflow and converted it into the very useful macro format. I use this almost every day and it saves me mountains of time so thanks, Susan!]

I’ve posted several articles in the past about using polygons in Tableau to display custom regions on maps. A common format for the source data in many of these cases is a shape file – either an ESRI .SHP file or a MapInfo .MIF file. Neither of these files can be read natively by Tableau (give the idea a big +1 on our forums) so we need to extract the boundary information into a format we can use.

I have been using Alteryx to do this for a long time – one of the key reasons is this:

020515_0156_UsingShapeF1.png

Alteryx has a great tool for generalising spatial data – i.e. it decrease the number of nodes that make up a polygon or polyline, making a simpler rendition of the original spatial object. That’s great as it gives control over the number of vertices we create (making the resulting TDE file smaller and faster) but the check box I’ve highlighted is the real magic. When checked, line segments that are shared by multiple objects are generalised together, ensuring no gaps or overlaps occur between those objects as otherwise can happen when you simplify:

020515_0156_UsingShapeF2.png

So here is the workflow I’ve been using for a while. It has two paths – one to generate the boundary vertices and one to generate the polygon centroids. The reason to generate both and how to use them is outlined here and here.

020515_0156_UsingShapeF3.png

The problem with this is it is complicated to rebuild every time I need to convert a shape file. Enter the Alteryx macro, where this logic can be wrapped up in a single, reusable object. Download the macro .YXMC file from here and put it into your C:\Program Files\Alteryx\bin\RuntimeData\Macros directory. Now all the complexity is hidden behind a single macro icon:

020515_0156_UsingShapeF4.png

And our workflow now looks like this:

020515_0156_UsingShapeF5.png

Enjoy!

About Alan Eldridge

Hi. I'm Alan. By day I manage the APAC sales engineering team for Snowflake Computing. By night, I'm a caped crusader. Or sleeping. Most often it's sleeping.
This entry was posted in Uncategorized. Bookmark the permalink.

7 Responses to Using Shape Files for Boundaries in Tableau

  1. Cynthia says:

    Thank you Alan and Sussan. A very useful macro and method!!

  2. Hi Alan,
    I am not able to download the macro. Can you please help me with the same?
    Thanks
    Vivek

  3. Pingback: Use Tableau to Create Census Tract Map – Data & Web

  4. Pingback: 3danim8's Blog - How to Convert Shapefiles to #Tableau Polygons

  5. Pingback: Best of spatial analytics for alteryx | adrianloong

  6. Pingback: Points and Polygons in Tableau 10.2 | The Last Data Bender

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s