How to make custom Tableau maps
Sometimes you're in need of a map that's neither native with Tableau or available online as a polygon map.
Let's say you need a map of your specific business districts or maybe mapping of lakes, parks and fields. The use cases can be many, but how do you handle not having the map at hand?
A customer of ours recently reached out with a request like this. He needed a more detailed seperation of some Danish cities, and of course we were up for the challenge.
With Alteryx the process of creating or modifying an existing map is actually quite simple. This guide will be based on modifying an existing polygon map (can be downloaded from //tableaumapping.bi), but the process of creating an entirely new map is quite similar as you will see.
Firstly we'll open Alteryx and create a base map from the polygon map you already have available.
Above you see how the data usually looks when working with polygon maps. The first step in creating the base map is to make a combined field of both the [PolygonID] and [SubPolygonID] which I did with the following formula "ToNumber(ToString([PolygonID], 0)+ToString([SubpolygonID],0))". This is done so that we only have one dimension defining which polygon is which.
The next step is to create actual spatial data points instead of the numbers we have indicating latitude and longitude. This is done with the Create Points tool
I then configured the tool pretty straight forward as seen below.
Now we have a whole series of datapoints that Alteryx can plot on a map, but we're not interested in points. We need polygons to have an effective map. Therefore the next step is to create polygons from the points we just created. The way to do this is through the Poly-Build tool.
The tool is configured as below. [Centroid] is the spatial data points we just created in the Create Points tool, [Detail] is our combined PolygonID and SubPolygonID field and lastly [Path] is just a renaming of [PointID].
Now we just output our result as an Alteryx database file .yxdb and we have our base map.
What we have done so far is basically just turning our already existing Tableau polygon map into something that Alteryx understands as spatial data. The map we created will now function as our reference map in the further creation of the final map.
We'll now begin the process of drawing new polygons to replace with old. To do this, we use the Map Input tool.
The Map Input tool have two different modes. Select and Draw. We'll need to use the draw mode.
Below the configuration pane can be seen.
The light blue area on the map is the reference map we just build, which is there solely to help us draw the new polygons precisely where we want them. Secondly we have the darker blue areas. These are the polygons that I have drawn. The output of the Map Input tool is a dataset of spatial points containing the polygons that have been drawn.
The polygons are simply drawn by selecting Polygon in the top pane and then simply mapping out your desired polygons.
The next thing we want to do is give each polygon a unique ID. Therefore we add the Record ID tool to the dataflow. To make sure we won't end up with duplicate polygon IDs when we insert our new polygons into the old map I use the Formula tool and multiply each Record ID with 10000.
Now we want to change the data from Alteryx spatial data into data that Tableau will actually understand and be able to build a map based on. To do that we use the Poly-Split tool.
The Poly-Split tool turns our polygons into a series of datapoints.
The next step is then to turn the spatial datapoints into actual lines of data. This we do with the Spatial Info tool.
From the Spatial Info tool we want to gather Lat/Long information, why we configure it as follows
Through the Formula tool I now create a field called Rank set it equal to 2 for all of our new polygons. This will later allow us to differentiate between new and old polygons in Tableau
Lastly I run the data through a Select tool to give each field an appropriate name.
Below you see the datastream creating the new polygons and making them ready for Tableau.
Now we create another datastream containing the Tableau polygon map we already had. We'll then filter the old data for "wrong" polygons and union it with our new polygons.
Firstly we take an Input tool and loads our old map data, then we use a Formula tool to once again combine the [PolygonID] and [SubPolygonID] to the new variable we call [Detail]. Furthermore we add the Rank field and set it equal to 1 for the old data.
Lastly we filter the dataset for Polygons we no longer want. I have simply plotted the map in Tableau and then seen which Polygons seemed wrong and filtered their PolygonIDs from the data.
Now all we need to do is union the two datastreams and output the mapping data.
Below you can see the entire module needed to modify a map.
After the Union tool I have made 3 different outputs. One creates a new Alteryx reference map for potential later use. One creates an Excel file with the mapping data. Lastly the new polygon map is uploaded directly to our Tableau Server.
And bam! We have our modified map ready to use.