A Guide to Mapping and Geographical Analysis in Tableau

Learn the basics of mapping in Tableau, how to create maps, use layers, area calculations, and other mapping features from Tableau Visionary Marc Reid.

This blog is part of a collection by Tableau Visionaries—the Tableau community's most distinguished leaders who inspire others by sharing their mastery, teaching, and collaborating.
 

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.

Tableau guide to mapping by Marc Reid

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.

​​Support for Multiple Data Sources

In version 2021.4 Tableau added the ability to use a different data source for each map layer. This makes creating maps from multiple sources of data much easier as it’s no longer necessary to create relationships or joins between those data sources.

Tableau mapping 2020.4 - 2021.4

Learn more about using map layers with multiple data sources in this video tutorial, in which three separate shapefiles are used to create multiple map layers:

1. Administrative Areas - polygons shapefile
2. Roads and streets - lines shapefile
3. Educational facilities - points shapefile

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, meters 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 visualizations:

The Area Calculation

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

Improved spatial joins

Spatial joins originally only supported joins between point and polygon geometries. The combinations of geometry types that can now be used has increased to include: polygon/line, polygon/polygon, and line/line enabling a wider variety of use cases. 

For example, with a shapefile containing line geometry of roads and a second shapefile with polygons of states, you could create a join to determine which lines cross state boundaries.

I hope you’ve found this overview of mapping features useful. Please explore the further resources below for more information on analysing your spatial data with Tableau.

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 visualization designer based in London and has been using Tableau since 2017. He shares Tableau tips and tutorials on his blog and YouTube channel, and can also be found on Twitter and Linkedin

Tableau Visionary