During an introduction Tableau training I showed how Tableau can connect to spatial files and create powerful maps. In addition, I used the Tableau & Mapbox integration to add a classic Mapbox map in the background!
After the training, one of the participants emailed me asking for advice on how to get started with Tableau, Mapbox and spatial files. For this reason, I decided to create a real example and write down all the necessary steps.
The real example consist of a map with the inhabitants of all the neighbourhoods of Amsterdam! I downloaded the data from the Centraal Bureau voor de Statistiek (CBS) in a shape file format and I will add a classic Mapbox map!
In summary, the steps I need to implement are the following:
- Connect to the spatial file
- Create the map of Amsterdam including all the neighbourhoods
- Add a classic Mapbox background map
Firstly, we need to connect to our data which in this case is a spatial file:
As we see below, the folder with the data contains .shp which indicates that my spatial file type is shape file:
Secondly, when you connect to spatial data, Tableau creates a Geometry field for your point geometries or your polygons. You use the Geometry field to create a map with your spatial data.
By adding the Geometry field to Detail on the Marks card, the Latitude (generated) and Longitude (generated) fields are added to the Columns and Rows shelves. A map view is created which in this case is an Amsterdam map. In addition, I added the BU_NAAM field which includes the Amsterdam neighbourhoods to Detail and the AANT_INW field to Colour on the Marks card.
The result is a filled map with the neighbourhoods of Amsterdam coloured with shades of grey and red depending on the number of people living in each neighbourhood:
At this point, I have built the map I wanted and the next step is to add the classic Mapbox background map. This can be achieved by clicking on Map -> Background Maps -> Map Services… as it is showed below:
When you left click on the Map Services… the following window is appearing:
There are two main options: Mapbox GL and Classic. In this example I want to add a classic Mapbox background map, therefore I select Classic.
In detail:
- Style name: Name the Mapbox map. This name can be anything you want, and will appear in the Background maps menu after you add the map.
- API access token: Paste the API access token from your Mapbox account. (If you don’t have a Mapbox account, you can get started with a free plan)
The Tableau map with the classic Mapbox background map is ready!
You can find the Tableau workbook here where you can download it!