Points and Polygons in Tableau 10.2

I have previously written about how we continue to add new features to Tableau and this means that we can develop better solutions to previously difficult problems. I’d like to present another example of this – where we want to plot points and polygons together on a single Tableau map. In an earlier blog post, I had shown how we could present points and polygons together in Tableau. However in Tableau 10.1 and earlier it was a complex process that required significant data preparation.

In Tableau 10.2 we are introducing a spatial file connector that will make it much easier to plot polygons and points together. You can now simply present your  polygon data to Tableau in an ESRI shapefile, KML or MapInfo file format:

2

and Tableau can directly plot the polygons:

1

Note that this is a much less complex viz structure than in earlier versions of Tableau. We are not using a vertex list anymore – we simply double-click on the new Geometry object (the globe field in the Measures section) and Tableau takes care of the rest. Note that in the above viz we have the (generated) latitude and longitude fields on the row/column shelves and the COLLECT(Geometry) measure on the details shelf.

When we want to overlay points on this polygon map, we simply need to have our point data also presented in a spatial file format. For this example, I had raw lat/lon data in a CSV and using Alteryx I converted it to a spatial object. I also used some of Alteryx’s spatial matching features to tag each location with the nameof the SA3 region in which it is contained (it will become clear later why this was done):

9

Once again we can simply connect to the resulting shapefile:

3

and plot the points on the map – note the layout of the viz is the same as for the polygon map above with the (generated) lat/lon fields and the COLLECT(Geometry) field on details:

4

To combine the two spatial data sets we can use the new cross-data-source join feature introduced in Tableau 10 to join the two shapefiles:

5

Starting with the previous polygon map, we can CTRL-drag the longitude field on the column shelf to duplicate the map and swap the COLLECT(Geometry) field on the detail shelf of the second map to show the Geometry field from the point location data source. Set the mark type to a red circle and you will see the following:

6

If we make the map a dual axis map, we now have points and polygons shown together. Yay! This is a much simpler (and more useful) solution compared to the previous approach.

7

Finally, because both data sets have the SA3 name we can use this to highlight both a polygon and the set of points therein, allowing for interactions that previously were not easy to do:

8

So thanks, Tableau development team, for adding these new capabilities and making old, complex techniques obsolete.

About Alan Eldridge

Hi. I'm Alan. By day I manage the sales consulting team for Tableau Software in Australia/New Zealand. By night, I'm a caped crusader. Or sleeping. Most often it's sleeping.
This entry was posted in Uncategorized. Bookmark the permalink.

17 Responses to Points and Polygons in Tableau 10.2

  1. Pingback: Points and Polygons | The Last Data Bender

  2. Chris McClellan says:

    Great work as always 🙂 I think this would really help my current situation, but can I get some more info on the Alteryx workflow ? (although I’m trying to solve it myself right now as well).

  3. Chris McClellan says:

    I got it working for my situation, thanks again 🙂 🙂

  4. David Pires says:

    This is brilliant, great new addition. Map layers are awesome.

  5. Pingback: How to geocode thousands of addresses and make a Tableau custom polygon + point map, with a little help from FME » Tableau Picasso

  6. craigsdewar says:

    Wow – no more fake maps in the background just to get dual axis lat/longs on the same map. Love it!

  7. Chris says:

    You can actually just drag a second set of coords onto the row/col shelves and choose a different mark type (e.g. shape) to get the filled polygon map and shapes in one graph. No need for the additional data transformation.

    • Hi Chris,

      Thanks for your comment however I’m not sure what you mean by “drag a second set of coords onto the row/col shelves”. In 10.2 the spatial field is represented by the geometry field and you can’t drag that to the row/col shelves – only to the detail shelf. It is used in conjunction with the generated lat/lon fields.

      You can duplicate the lat/lon fields on the row/col shelves and then associate them with different geometry fields – that’s what I’ve done in this example. The data prep was simply to get the SA boundary data and the volunteer data correlated so they could be joined (because we don’t currently support unioning spatial files directly in Tableau).

      I hope this clarifies.

      Cheers,
      Alan

  8. Andrew Davies says:

    Alan, this is great but I’m having trouble overlaying some data from excel – looking to add some population data at SA2 level, along with some specific location points as well. I have joined a KML file (from the ABS) with an SHP file (which I generated through an online converter that has 21 places marked, with an SA2 field that enabled the join). This follows your logic and appears to work. Things get a little funky when I try to add an excel spreadsheet of ABS population data that also has an SA2 name field. I can’t seem to get the union/join/blend right. Can you provide some guidance? Ideally I am trying to view population data when I select a specific location and drag a radius out – and I also have other uses for the SA2 location data.

    • Hi Andrew,

      I’d really need to see the data and understand what you are trying to do. You can send me a direct email to aeldridge at Tableau dot com and I’d be happy to take a look.

      Cheers,
      Alan

      • Andrew Davies says:

        Thanks Alan, I will do that, but my primary issue was that I was trying to join when I should have been blending my excel data (ABS data). I have resolved this, but I have another query so I will hit you up direct with that one. Thanks so much for this information though. It really opens up a lot of potential.

  9. Kevin Steenburg says:

    Hi Alan,

    This is an amazing and helpful tool that is going to work well for some of my dasboards going forward. I have a question though around sizing and colouring the points that are overlaid on the map. When I attempt to resize using the slider on the shelf containing my point geometry there is no change. When I bring another measure in to size by, most of the points disappear.

    • Hi Kevin,

      Thanks for the kind feedback. For your question – have you made sure you have changed the mark type from “filled map” to “circle”? For the point data, because the GEOMETRY field is a single point it will plot as a small circle when the mark type is “filled map” but you can’t resize this. You need to explicitly make the mark a circle or shape type.

      Let me know if this fixes your issue.

      Cheers,
      Alan

  10. Gabe Hollis says:

    Was wondering how you would go about randomly distributing specific points within a given polygon? I’ve downloaded a census boundary shapefile with population race data at the block level and need to distribute the given points randomly within a specified polygon. For example, at a specific block level I might have 20 Asian, 40 White, 60 African American etc. How would I go about plotting 20 specific points for the Asian variable within that set polygon? Any help is appreciated. Thanks.

    • Hi Gabe, why do you want to randomly place them within the shapefile? What does this achieve from an analytic perspective? My concern is that this could take away from the analytic accuracy of the viz as the viewer might think the random locations are actual data. Wouldn’t it be better to either a) just colour the boundary as a choropleth or b) place a single sized marker at the centroid of the polygon? This would preserve the analytic accuracy of the viz (i.e. the number you are showing is accurate the area, not specific points) and still communicate the same information.

      If you are dead set on doing this, the only approach I can think of would be some form of jittering around the polygon centroid, but you aren’t guaranteed that the points will be inside the polygon if you are dealing with complex polygon shapes (e.g. LGAs, postcodes… these all can be concave topologies, or could potentially have enclaves/holes within the outer hull).

      Your only certain path would be to prepare the data upstream of Tableau using some kind of GIS/spatial ETL package.

      Hope this helps.

      Cheers,
      Alan

  11. Hi Gabe, unless you generate the data point upstream from Tableau there’s no way to do this completely within the Tableau layer. However, even if you did, I suspect it would perform very slowly as you’d be plotting 1 dot per person and the population of WA is ~2.6 million. I’m not sure this is something that Tableau will be a good fit for.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s