A Zen Master’s Guide to Mapping

I read an enchanting book last year titled “Where the Animals Go”, by James Cheshire and Oliver Uberti. Through beautifully crafted maps, it explores the journeys and challenges of a variety of animals across different habitats around the world.

In the closing chapter, James talks about the parallels between his earlier research in studying human movements and what biologists were trying to learn from studying animals:

“What unites us is the appreciation that in order to fully understand why something happens we often need to know where it happens. Location is everything. And the way we study this is the same whether it relates to an ant, a diving whale or a person with a smartphone.”

With Tableau’s mapping features you too can explore geographical data and begin to answer those ‘where’ questions.


Mapping Key Concepts

Tableau can map three types of spatial data: points, lines and polygons. To know where these spatial objects should be drawn on the map, Tableau uses coordinates (either latitude and longitude or projected coordinates) and translates them to the right location on the web Mercator projection, which is the map projection used in Tableau and most tile-based web mapping systems. You can learn more about map projections here.

Pride Viz Gallery: Max Tham

If your data contains geographic fields, such as country names, cities, zip codes, airport codes or others, Tableau can automatically generate the relevant polygon (if it’s an area such as a country) or latitude and longitude values (for points) if they are contained within Tableau’s built-in geodatabase.

Alternatively, you can connect to spatial files, such as shapefiles, GeoJSON, KML and more, that contain the spatial objects you want to show on your map.


Creating a Simple Map

To create a map with any of these geographical fields, simply double click on the field in the data pane and Tableau will create a map using generated latitude and longitude fields. You can then encode the geographic points or areas in the view with a measure contained in your data.

In the below example I’ve connected to a shapefile containing polygons of the boroughs of London and joined this to an Excel file containing population density data. I then double-click on the Borough field to create a map of London and then add the Borough Name and the  measure to show the differences in population density across the city.

Pride Viz Gallery: Max Tham

Download the workbook here.


Using Map Layers to Combine Spatial Data

In version 2020.4, Map Layers were introduced, enabling you to layer multiple sources of spatial data on maps to create more comprehensive geographical views. Below is an example from Thi Ho that shows a map of Singapore with seven layers of spatial data, including population, rail lines, and parks:

Using Map Layers to Combine Spatial Data

Open an interactive version of the full dashboard on Tableau Public here.  Learn more about map layers and how they can be used in this blog post.


Integrating Spatial Functions

In the last two years Tableau has introduced some of powerful new spatial functions:

  • MakePoint - creates a spatial point from latitude and longitude values or projected coordinates if you know the SRID
  • Buffer - creates a spatial buffer (a circular object) with a user-specified radius around a spatial point
  • MakeLine - creates a line mark connecting two spatial points. The line created is a great elliptical arc meaning it takes into account the curvature of the earth.
  • Distance - returns the distance along the great elliptic arc between two spatial points
  • Area - (new in 2021.2) returns the total surface area of a spatial polygon
  • Spatial intersection joins - enabling joining of files based on spatial fields

These can be combined, enabling you to explore your spatial data in creative ways. The example below allows the user to explore Airbnb locations within range of a target location, select an Airbnb, and then see the number of car charging points within range of the selected Airbnb:

Integrating Spatial Functions

The above dashboard makes use of multiple data sources along with Buffer, MakeLine and MakePoint spatial calculations to create the interactive functionality. To learn more about how this dashboard was created see this blog post.


The Area Calculation

As mentioned earlier, in version 2021.2, Tableau’s latest release at the time of writing, a new spatial function was introduced. The Area calculation returns the square area in either miles, kilometres, metres or feet of a polygon in a spatial file that you have connected to.

In the below example I have connected to a spatial file containing the boroughs of London. To show the area of each borough in my dashboard I would previously have had to join the spatial file to another file that contained that information. Now Tableau can calculate that value directly from the shapefile and we can use it in our analysis and visualisations:

The Area Calculation

Learn more about the new Area spatial function in this blog post.


Mapping Resources

Mapping is such a feature rich area of the product that it’s impossible to cover everything in one post. Please visit the resources below to learn more:

Marc Reid is a data visualisation designer based in London, UK and has been using Tableau since early 2017. He writes about Tableau and data visualisation on his blog: datavis.blog and can also be found on Twitter and Linkedin

Assine nosso blog