Merging Two Polygon Maps In Tableau
In the spirit of returning things back to the Tableau community for wider benefit, I’m sharing a problem I recently solved while trying to map all 650 UK parliamentary constituencies. The resource on tableaumapping.bi is fantastic but only covers Great Britain and doesn’t incorporate Northern Ireland. If you’re trying to depict the full country, that’s obviously an issue.
I was able to lay my hands on a similar map for NI-only, but there’s no obvious way to merge them within Tableau. You can’t create a union of the two data sources without impeccable prevailing conditions, and nor can you blend them. The answer is a good old hack, and in this post I walk through the process I followed to get there, which others can apply to their own scenarios. The output .tde file I’ve made available on Google Drive here, and encourage anyone to use and disperse it.
The Original Problem
A previous post demonstrates what I was originally trying to do with this data – mapping petition activity to UK constituencies. I took the source polygon file from tableaumapping.bi and overlaid the data on top of that, but we only managed to cover 632 constituencies instead of all 650.
The other data source had the remaining 18, but the format of the fields and data was subtbly different. More importantly, some of the PolygonIDs appear in both data sources which would have considered Aldershot and East Antrim as one Polygon, with duplicate latitude and longitude for a single PointID.
1) For each set of polygon data, create the maps using the common fields that are available – at least PolygonID, PointID, Latitude and Longitude, but also preferably SubPolygonID and an identifier, such as place or region name
2) Select all the data items in the map, using the lasso or rectangle selector, and follow the usual route to View Data
3) Export it, which you can only do into a csv file
4) Repeat steps 1-3 for as many additional data sources you might have
5) Use basic MS tools or Google Sheets to append one to the other
6) Validate that you have no repeated PolygonIDs
7) Export as a CSV, setting the field headings to something that you can quickly make sense of in Tableau
8) Import the csv to Tableau, create a map to check that your combined geographical area is correct
9) Extract to a .tde to create a new file
10) Share the love
Again, here’s the link to download the file for all 650 UK Parliamentary constituencies.