To make latitude and longitude work in Tableau for mapping, you typically assign the appropriate geographic roles to your existing data fields. This tells Tableau how to interpret those numerical coordinates as specific locations on a map.
Understanding Geographic Roles in Tableau
Tableau uses Geographic Roles to understand how location data in your dataset relates to real-world geography. When you have fields containing numerical values representing latitude and longitude coordinates, assigning these roles is crucial for Tableau to plot them accurately on a map.
- Latitude: Assign this role to the field containing your latitude values.
- Longitude: Assign this role to the field containing your longitude values.
Once assigned, Tableau recognizes these fields as geographic coordinates, enabling you to easily build map views by dragging them onto the canvas.
Steps to Assign Latitude and Longitude Roles
If your dataset includes separate columns for Latitude and Longitude, you need to assign the corresponding geographic roles within Tableau Desktop.
Here is the general process:
- Ensure your data source contains distinct fields specifically holding Latitude and Longitude values. These are typically numerical fields.
- In Tableau Desktop, connect to your data source that contains the geographic coordinate fields.
- In the Data pane, locate the field that contains your latitude values. This field might be named something like
Latitude
,Lat
,Lt
, or similar. - Right-click on this latitude field.
- From the context menu, select Geographic Role > Latitude.
- Locate the field that contains your longitude values. This field might be named
Longitude
,Lon
,Ln
, or similar. - Right-click on this longitude field.
- From the context menu, select Geographic Role > Longitude.
After assigning these roles, the icons next to the fields in the Data pane will change to a globe symbol, indicating they are now recognized as geographic fields.
Example Steps from Reference
The provided reference illustrates this process using specific sample data and field names:
- Download the attached LongitudeLatitudeTestData.
- In Tableau Desktop, connect to LongitudeLatitudeTestData.
- In Measures, right-click Ln, and then select Geographic Role > Longitude.
- In Measures, right-click Lt, and select Geographic Role > Latitude.
These steps show how to assign the Longitude role to a field named Ln
and the Latitude role to a field named Lt
within the sample data.
Once the geographic roles are correctly assigned to your Latitude and Longitude fields, Tableau can automatically generate a map view when you drag these fields (often Latitude
and Longitude
generated by Tableau itself once roles are assigned) onto the Rows and Columns shelves.