Jim Dehner 

 Tableau Visionary and Ambassador

Tableau How to’s,  Use Cases, and Forums Questions

Hey #DataFam

Let’s Talk

Open for

Post Links

Tableau – Basic Mapping Techniques

Guest Author Don Wise – Tableau Community Forums Ambassador

 

 

 

Image Text

 

I think mapping in Tableau is one of the best features of the product.  In fact, it’s one of the core reasons my organization selected Tableau over the several available BI products on the market in 2013.  I started with Version 7 in 2012 on a trial basis, and when filled maps arrived in Version 8, that clinched the decision to select Tableau as our data analytics tool. 

 

As a bit of background, our organization provided support for thirteen fire departments and a local airport fire department in Los Angeles County. The genesis of selecting Tableau was due to the many Fire Chiefs of those departments needing answers to significant and particular business questions, related to spatial geography, time events, and other metrics.

 

 

We needed to know where the incidents were located on a map, alongside with other Computer-Aided-Dispatch (CAD) and 9-1-1 telephone data.  We needed to know how often we went to certain locations, how quickly Fire & EMS apparatus was responding to those locations, and related geospatial business questions about the services provided to the communities in the area.

 

We knew in 2012/13, that if Tableau was incorporating mapping features and functionality it would only get better.  And it has, in so many ways!

 

 

This blog though, is about the basics of mapping.  It’s truly easier to do than most may think.  Nothing to be frightened of and certainly a beneficial tool to use when attempting to answer spatially related business questions.  

 

By the way, a rule of thumb I try to always follow:  Ask what business question needs to be answered from the data.  Don’t simply throw out an analysis for analysis’s sake.  Don’t provide something that isn’t being asked for.  

 

 

Ask your counterparts: Is what you’re providing or developing going to be useful and also actively used? Is it needed?  Does it answer a business question?  If there’s any doubt, then it probably isn’t needed or it isn’t going to be truly meaningful. Ask, ask, ask!

 

 

Mapping Data & Partners

 

 

To start, we should first all understand what type of mapping data Tableau supports and where that underlying geodata comes from; whom Tableau partners with for that data.  When we talk about the underlying geodata, we’re referring to part of the package of data that comes with each installation of Tableau.  A certain set of files that serves as a reference database of sorts.

 

For example, I live in the State of California.  That can be represented in a couple of ways:

·       California (spelled out completely, field is labeled as State)

·       CA (abbreviation, field is labeled as State)

 

Tableau will reference its underlying data engine and attempt to match the data in the field to its underlying database. This is a generalization as there are other elements that play into this matching process to subsequently display the data onto a spatial map. More on that later.

 

Tableau supports worldwide airport codes, cities, countries, regions, territories, states, provinces, and some postcodes and second-level administrative districts (county-equivalents). U.S. area codes, Core Based Statistical Areas (CBSA), Metropolitan Statistical Areas (MSA), Congressional districts, and Zip codes are also supported by 

Tableau. Additionally, any latitude and longitude coordinates are supported by Tableau if they are in decimal degrees.

 

 

If you’d like to find out what level of detail is supported by each Country in Tableau, you can check out the following site.  As to which partners help to supply the underlying database for mapping purposes, there are quite a few:

 

Tableau maps and geocoding features use map data provided by the following partners:

 

 

 

Additionally, Tableau uses data from the public domain from resources such as Wikipedia. For the 115th U.S. congressional district boundaries, we use data from the US Census, the Virginia Division of Legislative Services (DLS), the Florida Senate, the North Carolina General Assembly (NCGA), and the Unified Judicial System of Pennsylvania.

 

 

Tableau also supports ESRI spatial files (.shp), ESRI GDB, GeoJSON, JSON, TopoJSON, MapInfo Interchange and Table formats, KML, and KMZ file formats.

 

Mapping Basics in Tableau – Creating a Simple Map

 

 

Using the Sample Superstore dataset found in each release of Tableau, let’s start with the following.  We’ll use visual markers in orange to focus on the area of detail in related screenshots.

 

1)    Open the dataset by clicking on the preview icon found under Accelerators at the bottom of the initial splash page:

 

 

 

 

2)    Click on the 2nd tab when Sample Superstore loads, which is the Overview Dashboard.  If you notice, not all worksheets for the dashboard are displayed.  This is by design of the creator that built the workbook, to simplify things for the end-user (you can always right-click the Overview Tab, then select Unhide from the list of options to show the related worksheets to the selected dashboard).

 

 

 

 

3)    Next, click on the Data Source Tab the very 1st tab in each workbook.  This will display the related and connected dataset for the particular dashboard you selected.  If you had selected a different dashboard and then selected the Data Source Tab, you might see a completely different dataset, structure, and view.  For now, we’re focused on just this data source which is Sample – Superstore.  

 

If you do not see the Sample Superstore dataset as shown below, go to the What If Forecast worksheet, then in the upper left corner of the Data Tab (just above the search field) where there are several data sources displayed, select Sample Superstore then go to the Data Source Tab.  Note the field list on the left is the same as the columns.

 

 

 

This means whatever action you do in either of those places is then reflected in both.  In Tableau, we have multiple ways of achieving the same thing.  While that may seem to be too much functionality, it makes achieving a result faster/easier, depending on your preference on where/when to make a change.  

 

Did you also know that almost everything in Tableau is clickable or right-clickable?  That each of those actions will display sub-menus related to that item?  The best way to learn/explore is by doing!  So, let’s do that now.  As shown in the above screenshot, we’re focused on which fields?  Those that have a ‘globe icon’ next to each field name.

 

This means that Tableau data type engine has recognized that these fields are geography-related and/or have data types that represent geospatial data.  In this example, we have five fields that are being represented with a globe icon:

 

·       Country/Region

·       Region

·       State/Province

·       State

·       Postal Code

 

Click on the globe icon for Country/Region and see what happens.  A contextual sub-menu opens and displays for you:

 

 

 

We can see that it has appropriately assigned the field as a String (abc/text).  But notice the additional options?  Click on Geographic Role in the submenu, it will display a new sub-menu of options:

 

 

 

 

This allows us to not only confirm that the correct geospatial category is assigned to this field, but it also allows us to change it if it’s not correct or to assign a calculated field to be a geographic category.  Notice all the options?  So, aside from some of the standard geography fields already noted above, we also have:

 

·       Airport, for 3-letter airport codes

·       Area Code, for the United States 3-digit area codes

·       CBSA/MSA, for United States Core-based and/or Metropolitan Statistical Areas

·       Congressional Districts, for the United States

·       NUTS (Nomenclature of Territorial Units for Statistics), Europe

 

Again, any latitude and longitude coordinates are supported by Tableau if they are in decimal degrees.  If your X, Y coordinates or latitude/longitude coordinates are in minutes, seconds, or degrees, there is a solution to reformat them by calculation here: Converting Degrees/Minutes/Seconds Coordinates to Decimal Degrees

 

 

And another reminder that Tableau also supports ESRI spatial files (.shp), ESRI GDB, GeoJSON, JSON, TopoJSON, MapInfo Interchange and Table formats, KML, and KMZ file formats. These are specialized spatial file formats, which also represent geography, a topic for a different blog. 

 

4)    Next steps, click on the New Worksheet icon.  It’s located to the bottom right and represented by a small icon that looks like a chart with a plus sign:

 

 

 

 

Or Command-T by keyboard/keystroke or find the same icon just above the Pages shelf, or go to the Menu, then Worksheet, then click the first item in the menu list which is New Worksheet.  Again, many ways of doing the same thing in Tableau.

Be sure that you’re using the Sample Superstore dataset.  It should be highlighted by a gray bar in the Datatab (upper left side of the view):

 

 

 

Then click on the Location field to expand it.  Note: When you see a > symbol next to a field, it means that it is a hierarchy.  It is an encompassing field with at least two if not more additional and related fields.  This serves a couple of purposes.  (1) to logically combine related field types (geography in this case) into one ‘combined’ field (2) to create a useable hierarchy that when used in the Marks Card and/or on Columns or Rows – displays a + sign in which the hierarchy can easily be expanded (going to a lower level of detail as structured in the hierarchy) by clicking the + sign and/or collapsed (going to a higher level of detail as structured in the hierarchy) by clicking the – sign.

 

 

 

In this Sample Superstore example, we have the following fields in the hierarchy related to ‘Location’.

·       Country/Region

·       Region

·       State/Province

·       State

·       Postal Code

 

Note that you do not always have to use a hierarchy.  You can always remove a created hierarchy by right-clicking the encompassing field name, then select Remove Hierarchy:

 


 

5)    Next, double-click Location.  Bet you thought it would create a map?  Nope.  All that does is simply open/close the hierarchy.

 

Next, double-click Country/Region from within the hierarchy field list. A number of things occur with just that single simple action of double-clicking a field. (1) the Marks Card was populated with Region/Country field (it also shows the [+] icon next to it meaning it is expandable to the level of detail found within the hierarchy.

 

 

(2) Tableau has created a map view automatically, representing the data found for that field.  Tableau will represent that data with two dots.  In geospatial terms, will use the verbiage points and Tableau has centered those points on a latitude/longitude for those areas (3) Tableau has automatically created two new fields (Latitude Generated) on Rows and (Longitude Generated) on Columns.  This makes sense because Latitudes are horizontal (east to west/west to east) and Longitudes are vertical (north to south/south to north)

 

Congratulations! You’ve just created a map.

 

Note: Latitude Generated and Longitude Generated pills are just that.  They generate and populate in their respective roles only when Tableau determines they can be used with the assigned geographic roles/data in the dataset.  Those points are actual Latitude and Longitude locations; Tableau references an underlying geodatabase file to generate the lat/lon based on the geographic role assigned to the data.  

 

Because they’re generated from an underlying file, you won’t see the actual Latitude and Longitude data associated with those points. However, if you were to go to Menu, then Worksheet, then Export, then Data (not crosstab), you’d see the related latitude and longitude information for each point as generated by Tableau with that software process.

 

6)    Now, go ahead and click the [+] sign in the Marks Card until there is no more ability to drill down.  You’ll notice that the map updates according to the level of detail found within the data:

Region:

 

 

State/Province:

 


City:

 


 

Postal Code:

 

No change as the data in the data set doesn’t contain any lower or different values, however, the tooltip will subsequently display the additional contextual information of the Post Code, associated with each City.

 

7)    Terrific.  So far, we’ve represented points of data on a map without much effort at all.  If your data is similarly structured, then you can easily do the same as well.  

One of the things that the Ambassadors often see on the Community Forums as an ongoing issue is badly structured/spelled data.  That’s generally something that Tableau is not going to fix on its own.  Badly structured or misspelled data will cause for errors or could be cause for Tableau to not display points or other geography.  

 

As an example, sometimes, we see data with the Field Name of Country.  The first row = Japan.  The second row = France.  The third row = London.  Two of those are countries, the third is not; it’s a city.  Tableau will not make the leap for you in correcting that situation.

 

This issue could be resolved in Tableau Prep, an ETL tool to clean/reshape your data.  Generally, each subscription license also allows for use of Tableau Prep to perform those types of actions ahead of importing the output of that cleaning/reshaping into Tableau Desktop.  But sometimes an organization may withhold that tool from someone creating a map, for whatever reason.

 

That means the data must be corrected in the original data source somehow OR sometimes (not always) it can be somewhat managed in Tableau Desktop.

 

As noted earlier, Tableau provides an underlying geodatabase of sorts which serves as a reference point to match incoming data.  It’s not always an exact match.  In other words, it’s not going to assume that AL for Alabama (a State) in the United States is the same as AL for Alberta (a province) in Canada.  To show what that would look like, I’m going to remove Region/Country and Region from the Marks Card, leaving just State/Province:

 

 

Canada goes away completely.  Sorry about that Canada 🇨🇦 …you get a flag here though!

 

But we get something new in the map.  Notice the very lower right-hand corner of the view.  A small gray icon.  It says 10 unknown.  If we click on that icon we’ll get a new dialog box that opens up.  Click on Edit Locations thereafter. This dialog box can be very useful for attempts to resolve situations like this:

 

 

 

 It’s showing that the focus is solely on the United States because the dimension of Country is no longer in the marks card.  There isn’t enough detail in the data for Tableau to make the connection that Alberta belongs somewhere.  In this case, all of the values are showing Unrecognized.  In other cases, they might show Ambiguous. 

By clicking on Unrecognized (or Ambiguous) you’ll get a list of options to select from to try and match upon.

 


 

You could enter a Latitude and Longitude for each of those issues; however, that would be extremely time-consuming and not efficient.  Hence, the need for data prep and cleaning.  In this case, it won’t do much good, but in some other cases (…it just depends on the cleanliness of your data…) it can sometimes be used to fix issues.  So be aware of that icon in the lower right corner of the map when it appears.

 

For more information: Geocode Locations Tableau Does Not Recognize and Plot Them on a Map or Assign a Geographic Role to a Field

 

8)    Back to our map basics. I’d like you to notice that Tableau, in the Marks Card, assigned the shape as a circle automatically to represent the point(s) on the map.  So long as that’s represented as a circle, you have the ability to also use the Size button in the marks card to adjust the size of the point.

 

Now, a note of caution here.  If you simply adjust the size of the point on its own, without any other frame of reference then that’s not a good thing to do.  That could lead the viewer to believe that the point is a certain size because of what?  You don’t want to lead the viewer; the data should be appropriately represented, and the viewer makes their own judgment based on where the data leads them.

 

So, select the Postal Code field from the Table list of Fields on the left in the Data Field Pane and drag another instance of it and drop it under the pre-existing (expanded hierarchy) then right-click and select Measure, then select Count.  To count the number of Postal Codes in each City:

 


 

Notice that it’s turned from Blue to Green?  It’s now been recast as a Measure (yes, you can count Dimensions!). Then, click the … ellipses next to the field name in the Marks Card.  From the contextual menu, select Size (essentially the same action as dropping the field onto the Size Button).  

 

 

Notice now, that we have representative sizing based on the count (number) of zip codes found in the data, across the map, and we have a new legend automatically generated for the Count of Postal Code (upper right portion of the view):

 

 

 

 

If for some reason you needed to, you can also adjust the legend by hovering on the title of the legend, clicking the down arrow, and then selecting from the context menu, Edit Sizes.  A new dialog window opens which looks like the following for any needed adjustments:

 

 

 

 So, this is a great example of showing some analysis by counting something and then using size to represent the count of something on a map.

 

9)    Another visually appealing method of creating additional viewer engagement is providing color to a map.

Using exactly the same method as before for the Count of Postal Codes, do this again so that there’s now an additional Count of Postal Code below the last one that was just created.  Instead of using Size or Text or Label or Tooltip though, this time click Color:

 


 

Now the viewer/user gets much more additional context and a new Color Legend on the right side of the view:

 

 

 Your color schema can always be adjusted by clicking on the Color Button, then Edit Colors. Color opacity and borders can also be applied through use of that button.

10)  What if though, I didn’t like or want this gray map?  What if I wanted something different or needed more detail to the map itself?  Easy enough to do!

 

Go to the Menu bar, then click on Map, then click on Background Maps, and then Dark for example:

    

 

 

 

 If you want more options, same steps as before, this time select Background Layers.  This will give you all kinds of options to select from, to use or not use, as needed:

 

 

Please note that background layers are just that.  Background.  They are essentially static.  The data are simply layered (displayed) on top of a static picture.  There’s no relationship between the data points and the background, so no ability to do geospatial analysis in those terms.

 

In the above dialog, there’s also an option to add a Data Layer such as US Population by Race.  Again, this is just a static, representative layer with no ability to use it in any other manner other than for display purposes.

Under this same Menu for Maps, we also have Map Options which allow you to control what the end user can either use or not use for controlling of the map:

 

 

 

The map controls display up on movement of the mouse and the controls display in the upper left portion of the map.  So, depending on what’s allowed, certain controls can either be enabled/unenabled.  I won’t go into any details on this as they’re straightforward. If you want more information you can check out the following: Customize How People Interact with your Map

 

11)  In these next steps we’ll do a bit of analysis by creating a simple Filled Map.  I’ve reverted back to a ‘Light’ map background.  And I’ve removed the two green ‘pills’ for Count of Postal Code from the Marks Card.  I’m also moving the hierarchy up to State/Province.  Why?

 

For a filled map, we need polygons or shapes.  While a circle is a shape and it is represented by City and Postal Code, it won’t be sufficient to represent a polygon shape and it is not a polygon. Can a series of points represent a polygon? Yes, but that’s for another blog post. And we don’t have that kind of data or data structure in the Sample Superstore data set.  The polygon shape is represented in this particular data set from State/Province upwards through Region and ultimately Country/Region.

 

So, we start with this:

 

 

Now, in the Marks Card, select the drop-down arrow next to the verbiage Automatic.  In the list of options to change the Marks Type, select the filled map icon and it also says Map. Substantial change there!  We went from points to polygons with just one click:

 

 

 

Note that we cannot use the Size Button here as these are polygons.  Their size won’t change.  But we do want to see some analysis, and we can use color for that.

Select Sales from the Data Field List and drag it onto the Color Button.

 


 

Select Sales again from the Data Field List and drag that instance onto the Label Button.  Now we have not only a nicely differentiated filled map based on sales volume but some context for the viewer/user as well:

 

 

 

 

If you’ve finished this, then you’re well on your way to doing more with mapping.  In the next blog post, we’ll focus on more intermediate mapping techniques such as Maps Marks Layers and Dual-Axis mapping techniques.  We’ll introduce some other things such as different data source types and related connections/joins.

 

In the meantime, if you’d like to try another mapping example, you can always use the following Get Started Tutorial as well.  Best way to learn is by doing!

 

Best,

 

 

Don Wise

Tableau Community Forums Ambassador

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *