KNOWLEDGE BASE

Creating an Origin and Destination Map with more than one Stop


Published: 11 Dec 2020
Last Modified Date: 11 Dec 2020

Question

How to Create an origin and destination map with more than one stop in Tableau.

Environment

Tableau Desktop

Answer

Step 1 - Ensure your data is prepared adequately

In this example, the data source needs to contain both Longitude and Latitude fields for both the origins and the destinations. In other words the data source must contain two longitude fields (one for destination, and one for origin), and two latitude fields (one for destination, and one for origin).

If your data does not contain such information, download a masterfile data set of airports location (some sites like transtats.bts.gov or openflights.org have data sources that contain such data and are available for download). Then, using Tableau Prep, add the new Airport location masterfile to your data source flow twice. Adding it twice will join the data and provide both latitude and longitude fields. For help on how to add joins in Tableau Prep, see Join your data in Tableau Help.

After exporting this flow, connect to it via Tableau Desktop. 

Step 2 - Build the view

  1. Create three calculated fields to build your map: 
    1. A Makepoint Destination Field to map the destination point on a map: MAKEPOINT([Destination LATITUDE],[Destination LONGITUDE])
    2. A Makepoint Origin Field to map the origin point on a map: MAKEPOINT([Origin LATITUDE],[Origin LONGITUDE])
    3. A Makeline field to create a line between two points on a map:  MAKELINE([MAKEPOINT_Origin],[MAKEPOINT_Destination])
  2. Drag the new Makeline calculation onto Detail to view the map
  3. (Optional) Change the Line color and Map layers as desired

To view Step 2 in action, see the video below.
Note: the video has no sound. To view the video in higher quality, click the YouTube icon below to watch it on YouTube directly.

Additional Information

For additional details about how to create Paths on Maps, or line tracing using coordinates, see the following documentation and examples: 
  1. Advanced Mapping Solutions on the Tableau website
  2. Create Maps that Show Paths Between Origins and Destinations in Tableau in Tableau Help
  3. The Batman Logo Evolution on Tableau Public (Note that the Batman logos are built by points in the X and Y axis. It is possible to virtually draw anything this way using Tableau by then generating a line to connect the dots)
  4. Using the Paris Metro example, the points need to already be in the database (each point should have a path ID so that Tableau Desktop can order them). Additionally, each point should have latitude and longitude data so that Tableau Desktop can plot them.
Did this article resolve the issue?