Who's Jared?

Jared is a Technical Writer in Seattle!

 

 

Intro

 

Have you ever wanted to do more with maps in Tableau?

 

Of course you have. Maps are cool. Maps make things come alive. There’s something about knowing that you’re not just looking at dots on a grid, but at cities full of breathing people and homes — you’re not just looking at lines, you’re looking at rushing rivers and busy highways.

 

So let’s talk about some things that you can do to personalize your maps and get more data into Tableau, starting with the quick stuff and graduating up to some longer projects.

 

Personalize your map and add layers

It’s easy to make a map in Tableau, but by default, maps don’t show a lot of detail. To fix that, click Map > Map layers… and select additional layers in the Map Layers pane that appears on the left. As a bonus, you change the map style and add some of Tableau’s built-in data as well:

Pic1.jpg

Pic2.jpg

 

Pic3.jpg

 

Select data quickly and approximate distances

Use the selection tools on the View toolbar when you need to select all the points within a section of the map.

Pic4.jpg

 

+ Zoom Area. Zoom into the area that you select.

+ Rectangular Selection. Select all the points in a rectangle that you draw.

+ Radial Selection. Select all the points within a certain radius from one point.

+ Lasso Selection. Select all the points within a free-form selection.

 

The Radial Selection tool is especially handy when you need to approximate the distances between nearby points:

Pic5.jpg

 

For those of you following along in Tableau, you might be surprised to find that there isn’t a distance measurement. You might even play around enough to experience something like this:

Pic6.jpgPic7.jpg

 

Wait, what? What gives Tableau? Turns out, there’s a good answer to this question though it’s not immediately obvious. The short answer is that you have to zoom in past a certain a level for the distance measurement to appear. For a longer explanation, see the note at the end.

 

Make a map with Mapbox

Starting with Tableau 9.2, you can connect to custom maps that you create in Mapbox, an online map provider. Check out their map gallery to get an idea of what you can do. Then, add your Mapbox map to Tableau:

1. Click Map > Background maps > Map services…

2. In the Map Services dialog box, click Add > Mapbox Maps…

 

For more information, see the Tableau documentation and the Mapbox documentation.

 

Add point data from shapefiles

A lot of geographic data that you find online is in the shapefile format, which is used to store points, lines, polygons, and lot of other data too. As of Tableau 9.2 however, you can’t open shapefiles in Tableau, which means that you have to find a way to convert your data to another format.

 

A good tool for this is QGIS, an open source geographic information system (GIS) program. (There are plenty of other tools available as well, like Esri ArcGIS, but chances are, if you have a license for those you already know what to do!)

 

Once you’ve installed QGIS, converting point data in QGIS is simple:

1. Click the Add Vector Layer button on the left.

Pic8.jpg

2.  Browse to your shapefile and open it. (In this example, we’re using the populated places data from the Natural Earth dataset here.)

3.  In the Layers Panel, right-click the populated places layer, then click Save As…

Pic9.jpg

4.  In the Save vector layer as… dialog box, select Comma Separated Value for the format.

Pic10.jpg

5.  Click Browse to select the location where you want to save the file, then click OK.

 

In Tableau, complete the following steps to make a map with the populated places CSV file:

1.  On the Connect section of the start page, click Text File.

2.  Select the populated places CSV file that you created with QGIS.

3.  Click Go to worksheet.

4.  In the list of Measures, double-click the Latitude measure, then double-click the Longitude measure.

+   A map with a single point appears.

5.  From the list of Dimensions, drag Name to detail.

+   The cities are displayed as points on the map.

6.  Optionally, from the list of Measures, drag Pop Max to Size on the Marks card.

 

Note: If you want to use shapefile data that contains lines or polygons, it’s going to take some more work. Try following along with the instructions here, here, and here.

 

Wrap up

Creating maps and working with geographic data can be extremely fascinating and rewarding—but we’ve only just scratched the surface! Here are some more resources to help you on your way:

 

+   Tableau maps documentation

+   Mapbox documentation

+   Setting up a web map service (WMS) server

+   An introduction to GIS

 

Footnotes

You must really like maps if you’re willing to read the footnotes! Here’s a longer explanation for why there’s a zoom-level cutoff for distance measurements:

 

Tableau uses the Web Mercator map projection to display its map data. This is the same projection being used by most maps that incorporate web data, and in fact, Google, Bing, and a lot of other companies use some variation of this projection.

Why does that make a difference? Because map projections exist for the sole purpose of transforming data on a sphere to data on a flat surface—think of unpeeling an orange, only instead of ripping the skin you find a way to stretch it in certain places to make a rectangle. When you’re choosing which parts of the skin to stretch, you’re deciding how the surface is going to get distorted.

 

Some maps, like Web Mercator, stretch the world to preserve directionality—that is, straight lines on the map always correspond to directions so that north is always north. (Fun fact, this is why the regular Mercator projection came into vogue, because seafarers and explorers could count on it to get from one place to another.) Other maps however, try to preserve distances or areas.

 

As an example, take a look at these two maps:

Pic12.jpg

The Web Mercator map projection.

Pic13.jpg

The Gall Peters map projection.

 

As you can tell, the map projection makes a big difference to how we measure distances and areas. Not only does Web Mercator distort measurements over long distances, it also distorts distances more and more the farther away you get from the equator. As a result, Tableau only gives distance measurements when you’ve zoomed in enough for the measurements to be useful rather than misleading.

 

Thanks for reading!

Jared