Importing Custom Geocoding into Tableau
Tableau Desktop recognizes a set of geographic roles that can be used to automatically geocode your data and create map views. For example, Tableau Desktop recognizes country names, state/province names, city names, and area codes.
If your geographic data does not fit into the built-in geographic roles, you can create new geographic roles and assign them to the geographic fields in your data. For example, if your data contains country, state/province, and street address data, Tableau Desktop will aggregate your data to the country and state/province level, but will not recognize the street address data as a geographic role. In this case, you can create a custom geographic role for the street address data.
Become a Master of Tableau 10 by going with Mindmajix online Tableau course.
If you had to go through the trouble to add customized geographic coordinates, wouldn’t it be better to make it available to other people within your organization? This is done by importing the address coordinates directly into Tableau Desktop. After they are imported, the custom locations behave like Tableau’s default geographic units. The import file should have the following characteristics:
- Give each location to record a unique identifier (key record).
- Save the location file in comma-delimited CSV format.
- Label the coordinate fields as Latitude and Longitude (these keywords must be used).
It’s best not to include a lot of additional dimensional data in these important files. Be sure that you have only one instance of Tableau open when you perform the import. If you want to share this custom data with other people building reports in Tableau, store the list in a shared network directory so that other users can import from the same list as well. Figure 5.11 is an example of a custom geocode table properly formatted for import.
Figure 5.11: Custom geocode table
After saving the custom list in comma-delimited CSV format, the custom geographic data can be imported into Tableau. Initiate the import using the main menu (map/ geocoding/ import custom geocoding). A small file will only require a few seconds to load. Large lists can take up to several minutes. Running the import will create a new data file on your computer within (My Tableau Repository/ Local Data). The custom data is stored as a Tableau data source file (TDS) with the same name as the source CSV file which was imported earlier.
Subscribe to our youtube channel to get new updates..!
Once you have created a .csv file with custom geocoding you can import that file into Tableau. Follow the steps below to import a new geographic role.
- Click Map > Geocoding > Import Custom Geocoding.
- In the Import Custom Geocoding dialogue box, click the button to the right of the text field to browse to the folder your import file is saved in. All files in the folder will be imported into Tableau.
- When finished, click Import.
The custom geocoding data is imported into the workbook and the new geographic roles become available. To assign a new geographic role to a field, right-click the field in the Data pane, select Geographic Role, and then select the role you want to assign it.
Using Custom Geographic Units in a Map
After importing custom geocodes into Tableau Desktop you can use them with other data files to build maps as long as those files contain the same location key record defined in your data import table. The custom data file used in the rest of this example looks like the one in figure 5.12.
Figure 5.12: Warehouse location table
Notice that there is no longitude or latitude data in the table shown in Figure 5.12. However, the (Whse) field can be used to link the imported data from the custom geocode table displayed in Figure 5.11. The steps to use custom geocoding in this example are:
- Attach Tableau to a data source.
- Alter the geographic role of the key records (use the imported custom geography).
- Use the key record in your view to plot the location on a map.
Altering the geographic role of the warehouse location is done by right-clicking on the Whse field, selecting Geographic Role/ Whse as you see in Figure 5.13
Figure 5.13: Altering the geographic role
The whole field icon will change to an icon that is similar to a standard geographic icon, but with a small list in front of the globe. Tableau will now recognize the imported geographic data. Figure 5.14 shows a map plot of the custom geocoded warehouse locations.
Figure 5.14: Warehouse location map
Notice that the column and row shelves are using tableau’s (generated) latitude and longitude fields. However, the warehouse marks actually use imported custom locations to place the marks. Hovering over the Los Angeles location causes a customized tooltip to appear, showing particulars about the warehouse zooming in on the Los Angeles location. In figure 5.15, you can see that the mark is more precisely placed than tableau’s standard geocoding can provide. This detail comes from the imported geocodes you saw in figure 5.12.
The order of the steps for enabling custom geocodes, at the beginning of this section isn’t the only way to achieve the result. You can import the custom geocoding at any point-even after a map plot is done using standard geographic plotting.
Now that you’ve learned how to precisely plot any location on a map with custom geocoding, in the next section you’ll learn how to replace tableau.
Figure 5.15: Los Angeles warehouse
Replacing tableau’s standard maps
Tableau maps visualization is special scatter plots that use map images for backgrounds and special measures (longitude and latitude) to plot marks on the map. This implies that you can replace Tableau’s standard map images with other image files.
List Of Tableau Courses: