KNOWLEDGE BASE

Plotting Two Sets of Latitude and Longitude on a Map


Published: 22 Jan 2013
Last Modified Date: 19 Jun 2017

Question

How to plot two sets of latitude and longitude coordinates, from different data sources.

Environment

Tableau Desktop

Answer

Open a workbook and connect to data

  1. Compare the structures from the two data sources to determine any differences in the field names and types.
  2. Open Tableau Desktop and connect to one data source.
  3. Drag a table to the canvas.
  4. Select New Custom SQL.
  5. Write a UNION query that creates a common set of fields between the two data tables, such as in the following example:

    SELECT [MapPoints1$].[Location_Name] AS [Location_Name],
    [MapPoints1$].[Latitude] AS [Latitude],
    [MapPoints1$].[Longitude] AS [Longitude],
    [MapPoints1$].[Type] AS [Type],
    "A" as [Source]
    FROM [MapPoints1$]
    UNION
    SELECT
    [MapPoints2$].[Location_Place] AS [Location_Name],
    [MapPoints2$].[Latitude] AS [Latitude],
    [MapPoints2$].[Longitude] AS [Longitude],
    [MapPoints2$].[TypeOfPlace] AS [Type],
    "B" as [Source]
    FROM [MapPoints2$]

  6. Click OK.
  7. In the Data Connection dialog box, select Connect live or Import all data.

Create the map view

  1. Drag [Longitude] (not [Longitude (generated])] to the Columns shelf.
  2. Drag [Latitude] (not [Latitude (generated)]) to the Rows shelf.
  3. Drag [Location_Name] to Label on the Marks card.
  4. Drag [Type] to Color.

Additional Information

The field [Source] may be used to differentiate between the two original data sources for calculations. 
Did this article resolve the issue?