Choropleth Map with Tableau Public
We first introduced you to the free Tableau Public desktop application (for Mac or Windows) when building scattercharts and filtered line charts in Chapter 6. Now let's use the same tool to create an interactive choropleth map, and compare the process with the Datawrapper tool we learned in the prior section. We're showing you how to create the same type of map with both tools, in order to show you the difference. On one hand, Datawrapper gives you more control over interpolating data and shaping the appearance of color intervals in your choropleth map. On the other hand, some people prefer Tableau Public because they're already familiar with its interface.
Tableau Public can create many different types of map for geographical place names or ISO codes it already recognizes, such as nations, states, counties, and airports. But Tableau Public cannot geocode street addresses by itself, so you'll need to obtain their latitude and longitude with another tool, such as those described in the geocode section of Chapter 2. Furthermore, if you want to upload customized map boundaries, learn how to Create Tableau Maps from Spatial Fileson the support page.
Data visualization is key to understanding data and to be able to clearly communicate insights. That is why many companies make use of data visualization tools like Tableau. Tableau Public is a. Tableau Reader is a free tool which allows us to view the visualizations and workbooks, which is created using Tableau Desktop or Tableau Public. The data can be filtered, but modifications and editing are restricted. There is no security in Tableau Reader as anyone can view workbook using Tableau Reader. What is Tableau? 'Tableau is a trending and market-leading BI tool used to visualize and analyse your data in an easily digestible format. It allows you to work on live data-set and spend more time on data analysis rather than data wrangling.' Well this was just an overview of Tableau, let's proceed and understand what is Tableau. It is a tool that allows one to view visualizations and workbooks generated using Tableau Public or Tableau Desktop. This data can easily be filtered, yet modifications are limited. Since anyone getting the workbook can view it using Tableau Reader, there is no security. What is Tableau Server?
In this section, we will create a choropleth map of healthcare spending per country as a percentage of their gross domestic product (GDP), as shown in Figure 7.52. Remember that choropleth maps work best when we normalize the data to show relative, rather than absolute, numbers. Creating a map of total health spending per country would not be very meaningful, as larger nations tend to have larger economies, so we'll base our map on the percentage of their economy that is spent on healthcare.
Before we start, you should obtain and install the free Tableau Public desktop application if you don't have it yet. It is available for Mac or Windows. You will need to enter an email address to download the application.
Figure 7.52: Choropleth map of healthcare spending with Tableau Public. Explore the interactive version. Data from the World Bank.
Let's look at the steps involved to create a choropleth from Figure 7.52 in detail.
- Open the Healthcare Spending by Nation as Percent of GDP data in Google Sheets, which we downloaded from the World Bank. Examine the data and the notes.
Good maps often require cleaning up messy data as described in Chapter 4. In our spreadsheet we removed rows for nations that did not report any data. Tableau Public recognizes many different types of geographic names (such as cities and nations), so we will rely on the tool to deal with any spelling issues and properly place all of them on the map.
In the Google Sheet, go to File > Download and select Comma-Separated Values (CSV) format to save the data to your local computer.
Launch Tableau Public. When you first open it, you will see the Connect menu on the left-hand side that displays file formats you can upload. Choose the Text file format and upload the healthcare spending CSV data file you've just downloaded in the previous step.
Note: Tableau lets you access data directly from Google Sheets that live in your Drive using Connect > To a Server option. So instead of downloading a CSV file in step 2, you could have made a copy of the sheet, and connected to it directly.
- In the Data Source screen, inspect the dataset, which contains three columns: Country Name, Country Code, and Health Spending As % of GDP. Notice that a small globe appears at the top of the Country Name and Country Code columns, which shows that Tableau Public successfully recognized these as geographic data, rather than string or text data. Sometimes Tableau does not recognize location data automatically, so you need to manually change the data type. To do so, click the data type icon (e.g. globe or a green
#
for numeric values), and then choose Geographic Role > Country/Region as shown in Figure 7.53.
Figure 7.53: Make sure Tableau Public knows that the Country Name column contains geographic data.
- In the bottom-left corner, click the orange Sheet 1 button to create a worksheet with your first visualization, as shown in Figure 7.54.
Figure 7.54: Click the orange button to go sheet 1 where you can create your map.
- In Sheet 1, create your choropleth map using a two-step process, as shown in Figure 7.55. First, drag-and-drop the Country Name field into the middle of the worksheet (alternatively to the Detail box of the Marks card) to create the map. The default view is the symbol map, which we need to replace with a polygon map. To add colored polygons, drag-and-drop the Health Spending As % of GDP field into the Color box of the Marks card to transform it into a choropleth map.
Figure 7.55: Drag and drop Country Name to the center of the sheet, then Health Spending As % of GDP to the Color box in the Marks card.
Tableau Public may hide the map legend behind the Show Me menu in the upper-right corner, so click the menu to shrink it and display your legend.
You can change the color palette by clicking the Color box of the Marks card, andthen Edit colors. Change the palette to Green, and change it from continuous to steps,as shown in Figure 7.56.
Figure 7.56: Change the color scheme to Green with 5 steps.
- When you hover over countries, you will notice a tooltip that tells you the name of the country and gives you the percent value. It is generally well-formatted as our initial data table had proper column headers. But we can make the toolitp even better. Click the Tooltip box of the Marks card, change the first instance of
Country Name
to justCountry
(do not change the grayed-out text inside<
and>
as these are variable names), and add a%
sign at the end of the second row, as shown in Figure 7.57.
Figure 7.57: Change tooltip text to make it more user-friendly.
Let's make our map title more meaningful. Double-click the default Sheet 1 name just above the mapto bring up the Edit Title window, and change the name of your chart to2017 Healthcare Spending by Country as % of GDP.
At this point the data is loaded and should be displayed correctly, so we are going to create the final layout that include map's title and credits, the legend, and is appropriate for sharing. At the bottom-left of the program, create a New Dashboard, as shown in Figure 7.58. Dashboards in Tableau are layouts that can contain visualizations from multiple sheets, as well as text boxes, images, and other elements, creating rich exploratory interfaces. In this tutorial, we will stick to just a single sheet that contains our choropleth map.
Figure 7.58: Before you publish the map, create a new dashboard to finalize your layout.
- In your Dashboard 1 tab, change the size of the dashboard to Automatic so that the map is responsive and occupies 100% of the width on all devices. Drag and drop Sheet 1 to the Drop sheets here area, as shown in Figure 7.59. This will copy the map, the title, and the legend from Sheet 1.
Figure 7.59: To create a responsive dashboard, change the Size to Automatic.
- Right-click the upper part of the map legend, and select Floating, as shown in Figure 7.60. Now you are able to place your legend directly on top of the map to save space. Drag and drop it to one of the map's corners.
Figure 7.60: To place the legend on top of the map, make sure it is floating.
- Finally, let's add a text block with data source underneath the map. From the Objects menu in the left-hand side, drag and drop Text to the lower half of the map. In the Edit Text window that appears, type Data by the World Bank, 2017, and click OK. Initially the text area will occupy half the height of the screen, so resize it like you would resize any window on your computer.
And we're done! Make sure you position your map's center and zoom level as you want it to be visible by others. In this case, the best would be to have a world view as we are showing data for most countries, although you may want to zoom in to a specific continent. Once you are ready to publish and share the map, go to File > Save to Tableau Public. In the pop-up window, log in to your account if requested. Give it a title, such as Healthcare Spending, and click Save. See how to embed the map as an iframe in Chapter 9.
Warning: Tableau may not be the best tool to create choropleth maps where you want to have full control of color breaks. By default, Tableau uses a linear color scheme that, as we've learned earlier in the chapter, is prone to highlighting outliers, and there is no straightforward way to change the intervals to non-linear methods such as quantiles. If you are not happy with the way the linear scale represents your data, you can filter your data to remove outliers from the map, or see Andy Kriebel's VizWiz tutorial to use table calculations to group items into quantiles, or create your choropleth map in Datawrapper, which gives you more control over color intervals and interpolation.
In all of the prior tutorials, you created interactive maps using static data, meaning it came from a spreadsheet. In the next tutorial, you'll learn how to build a map using continuously-updated data from a Socrata open data repository, which will always display the most current information.
A list of Tableau tools:
- Tableau Desktop
- Tableau Public
- Tableau Online
- Tableau Server
- Tableau Reader
Data analytics in Tableau is classified into two parts:-
- Developer Tools:- The Tableau tools which are used for development such as the creation of charts, dashboards, report generation and visualization are known as developer's tools. Tableau Desktop and the Tableau Public, are the example of this type.
- Sharing Tools:- The role of these tools are sharing the reports, visualizations, and dashboards that were created using the developer tools. The Tableau tools that fall into this category are Tableau Server, Tableau Online, and Tableau Reader.
Let's see all the Tools one by one:
Tableau Desktop
Tableau Desktop has a rich feature set and allows us to code and customize reports. Right from creating the reports, charts to blending them all to form a dashboard, all the necessary work is created in Tableau Desktop.
For live data analysis, Tableau Desktop establish connectivity between the Data Warehouse and other various types of files. The dashboards and the workbooks created here can be either shared locally or publicly.
Tableau Public Tool Box
Based on the connectivity to the publishing option and data sources, Tableau Desktop is also classified into two parts-
- Tableau Desktop Personal:- The personal version of the Tableau desktop keeps the workbook private, and the access is limited. The workbooks can't be published online. So, it should be distributed either offline or in Tableau public.
- Tableau Desktop Professional:- It is similar to Tableau desktop. The main difference is that the workbooks created in the Tableau desktop can be published online or in Tableau server. In the professional version, there is full access to all sorts datatypes. It is best for those who want to publish their workbook in Tableau server.
Tableau Public Dashbaords
Tableau Public
This Tableau version is specially built for cost-effective users. The word 'Public' means that the created workbooks cannot be saved locally. They should be kept on the Tableau's public cloud, which can be accessed and viewed by anyone.
There is no privacy of the files saved on the cloud, so anyone can access and download the same data. This version is the best for them who want to share their data with the general public and for the individuals who want to learn Tableau.
Tableau Online
Its functionality is similar to the tableau server, but data is stored on the servers that hosted on the cloud, which is maintained by the Tableau group.
There is no storage limit on the data which is published in the Tableau Online. Tableau Online creates a direct link over 40 data sources who are hosted in the cloud such as the Hive, MySQL, Spark SQL, Amazon Aurora, and many more.
To be published, both Tableau Server and Tableau online require the workbooks that are created by Tableau Desktop. Data that flow from the web applications say Tableau Server and Tableau Online also support Google Analytics and Salesforce.com.
Tableau Server
Tableau Public Tooltip
The software is correctly used to share the workbooks, visualizations, which is created in the Tableau Desktop application over the organization. To share dashboards in the Tableau Server, you should first publish your workbook in the Tableau Desktop. Once the workbook has been uploaded to the server, it will be accessible only to the authorized users.
It's not necessary that the authorized users have the Tableau Server installed on their machine. They only require the login credentials by which they can check reports by the web browser. The security is very high in Tableau server, and it is beneficial for quick and effective sharing of data.
The admin of the organization has full control over the server. The organization maintains the hardware and the software.
Tableau Software
Tableau Reader
Tableau Public Dashbaords
Tableau Public
This Tableau version is specially built for cost-effective users. The word 'Public' means that the created workbooks cannot be saved locally. They should be kept on the Tableau's public cloud, which can be accessed and viewed by anyone.
There is no privacy of the files saved on the cloud, so anyone can access and download the same data. This version is the best for them who want to share their data with the general public and for the individuals who want to learn Tableau.
Tableau Online
Its functionality is similar to the tableau server, but data is stored on the servers that hosted on the cloud, which is maintained by the Tableau group.
There is no storage limit on the data which is published in the Tableau Online. Tableau Online creates a direct link over 40 data sources who are hosted in the cloud such as the Hive, MySQL, Spark SQL, Amazon Aurora, and many more.
To be published, both Tableau Server and Tableau online require the workbooks that are created by Tableau Desktop. Data that flow from the web applications say Tableau Server and Tableau Online also support Google Analytics and Salesforce.com.
Tableau Server
Tableau Public Tooltip
The software is correctly used to share the workbooks, visualizations, which is created in the Tableau Desktop application over the organization. To share dashboards in the Tableau Server, you should first publish your workbook in the Tableau Desktop. Once the workbook has been uploaded to the server, it will be accessible only to the authorized users.
It's not necessary that the authorized users have the Tableau Server installed on their machine. They only require the login credentials by which they can check reports by the web browser. The security is very high in Tableau server, and it is beneficial for quick and effective sharing of data.
The admin of the organization has full control over the server. The organization maintains the hardware and the software.
Tableau Software
Tableau Reader
Tableau Public Account
Tableau Reader is a free tool which allows us to view the visualizations and workbooks, which is created using Tableau Desktop or Tableau Public. The data can be filtered, but modifications and editing are restricted. There is no security in Tableau Reader as anyone can view workbook using Tableau Reader.
Tableau Public Tools
If you want to share the dashboards which are created by you, the receiver should have Tableau Reader to view the document.