Custom geocoding is a technique used to assign latitude and longitude coordinates to locations so Tableau can plot them accurately on a map. Geocoding is of great use for many industries, including transportation and logistics companies. These businesses often divide customers into geographical zones for sales, delivery, marketing, and customer service perspectives. Geocoding is also used for analytical policing purposes in which intelligence agencies keep tabs on crime sensitive locations using geographical coordinates.
In this guide, you will learn how to do custom geocoding in Tableau.
To incorporate geocoding in Tableau, you need data containing a list of geographic data points, for example, any country with its corresponding states, cities, or counties. You also need the respective coordinates, that is, latitude and longitude.
In this guide, you will use two fictitious datasets. The first, named Florida Small Towns, consists of 15 records with variables
The second dataset, named Florida Latitude and Longitude, consists of 15 records with five variables:
The first step is to load the data into Tableau. To begin, open the Tableau desktop and look at the Connect pane.
Select More from the To a File option.
The above step will create an option for you to select the file from your system location. Now, drag the Florida Small Towns file into the canvas.
The lower half of the canvas provides the data grid, which can be used to view the data.
The next step is to open the sheet. You can see below that the variable
City is in the Dimensions part of the pane, while the coordinates, the latitude and longitude, are in the Measures section.
City into the Detail card of the Marks pane. This should automatically plot the detected latitude and longitude in the view. Another option is to drag
Longitude into the Columns shelf and
Latitude in the Rows shelf.
You would expect the locations to be plotted, but that’s not the case, as seen above. This is also highlighted with the message "15 unknown," shown at the extreme right bottom in the view. To understand this further, go to the Map menu in the toolbar section and select Edit Locations.
That will generate the following tab.
In the above output, you can see that the Country/Region selected is India. This is incorrect as we are looking for locations in Florida. You will have to fix this.
To fix the incorrect location, select the drop-down option, select United States, and click OK.
This will reduce the unknown locations from 15 to five. Go back to the Edit Locations option as explained above, and check for places where Tableau is not able to plot. This is shown below.
The output above shows that the locations Stuart, Waldo, and Williston are Ambiguous, while the other two locations, Lebanon Station and Matlacha, are not recognized by Tableau.
There are two methods to fix this.
Let's look at each of these solutions. For manual entry, go back to the Edit Locations option. Next, click on Enter a Latitude and Longitude option, as shown below.
Enter the correct coordinates as shown below and click OK.
Post the above correction. There are now four locations that are unknown. You can correct these manually, but you will have to use the second approach of importing the CSV file with the correct coordinates.
To implement this, create a new sheet and go to the Map option in the toolbar. Select the option Geocoding, followed by Import Custom Geocoding.
Next, browse the CSV file containing the coordinates of latitude and longitude in your system. This data is in the file named Florida Latitude and Longitude, which was discussed in the beginning.
The following output is displayed while the file is loaded.
Once the file is loaded, drag the
City column into the Detail card of the Marks pane.
You can see that the final output above has all the locations with zero unknowns.
In this guide, you learned how to use custom geocoding in Tableau. You also learned how to manually assign latitude and longitude coordinates in case of missing locations. This will strengthen your skills in dealing with spatial data.
To learn more about visualization and data analysis using Tableau, please refer to the following guides: