One fun part when using spatial data in Tableau is that you not only can create dots and areas on a map but even routes or paths. Today we learned how to do that by looking at the London bus routes.
You will want to have a dataset in a long format, in our example this means that each row in the data represents one stop of a bus line which in turn is then represented in several rows.
The combination of the longitude and the latitude data will result in the specific location of that bus stop. We can achieve this by using the MAKEPOINT([Latitude], [Longitude]) formula in a calculated field. But before that make sure that your latitude and longitude columns are defined as spatial data. When working with data from another country Tableau might have changed it automatically to a string. You can change this by setting the text file properties of the data source to the country you need.
As latitude and longitude are measures you’ll receive an aggregated view of the data on a map when dragging them onto the canvas. You could also disaggregate the data and work with two dimensions and in this case get the same result, but we’ll stick with the first option for now.
Tableau will automatically identify the number of the bus line as an integer and thus a measure which is understandable but not what we need – so change the bus line to a dimension and a string and then drag it onto the detail marks. Now you get one dot for every bus line in London. Make sure to make the number of the bus stop (“Sequence” in this example) a dimension as well but keep it as an integer.
When changing the marks type to a line chart the map will look as it is having a heart attack. Because nobody wants that, simply drag the bus stop dimension onto the path mark and you’ll get a nice map of the London bus routes.
You can then play around with colors, filters and formatting depending on the purpose of this map.