[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:
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:
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.
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:
And our workflow now looks like this: