MLearning.ai
Published in

MLearning.ai

How to create flight path maps in Tableau? Example

If you have a task to create a flight path map to show the impact of COVID-19 on air traffic or show your company delivery chain —brace yourself, it’s a tricky one!

https://public.tableau.com/shared/HWDM496P8?:display_count=y&:origin=viz_share_link

Perhaps the biggest challenge you would face is not the Tableau syntax but the chores around the data — data cleaning, data union, finding missing values, and data join.

Let me tell you about the process.

STEP 1. Prepare the data. To create a flight path map, you need the following information in your databases:

(1) start and end locations (for example, departure and destination airports),

(2) airport coordinates (latitudes and longitudes for both arrival and departure),

(3) and trend information, for example, an arrival delay.

Surprisingly, there are a lot of databases over the Internet that don’t contain enough dimensions.

In this example, we will use Flight routes across the USA in 2015 Historical data, simply because this database contains all necessary information. You need to download all three .csv files — flights.csv, airports.csv, airlines.csv.

In most cases, the information is represented in separate tables (for example, airlines, airports, flights), and you need to use union and join functions.

Visualization should be meaningful and answer the user’s question, right? This free data provided by The US Department of Transportation’s Bureau tracks the performance of domestic flights operated by large air carriers. Hopefully, we could display the arrival delays to show the end-user an average arrival delay by the location.

How long are flights usually delayed in the US — by the airport

STEP 2. Really important step: create a SELF-UNION.
Remember: in order to draw two lines, Tableau needs a start point and an endpoint.

So, when you uploaded the data, it’s time to make a union. Why? Usually, a table contains only one record in your datasets. Tableau can create a route only with two records. You need to DUPLICATE your initial table to make it work. Whereas JOINS work with columns, UNIONS work with rows.

2.1. Create a self-UNION

  • Drag flight.csv file under the first one flight.csv ‘Drag table to union’

You can see the following changes:

(1) the name changes to routes.csv+,

(2) when you click on the arrow, the function ‘Edit Union’ opens, make sure there are two tables inside

Edit Union Flights.csv

(3) a new field called ‘Table name’ has appeared in your table

A new row — Table Name

STEP 3. Create a Root / Path

3.1 Create a Route Identifier

  • Go to the ‘Origin Airport’ column— click on ‘Create Calculated Field’
Create Calculated Field from Original Airport column
  • Create a Route identifier with a function [Origin Airport] + “_” + [Destination Airport]
Route Identification function

You can see a new column, ‘Route Identification’, with the starting and endpoints. For example, ANC_SEA of LAW_PBI.

Route Identification: from the origin airport to the destination airport

3.2. Create a Route order

Tableau needs to know the path orders between locations so that the next step would be creating the route order.

  • Go to the ‘Table Name’ column— click on ‘Create Calculated Field’
  • Use the following function IF [Table Name] = ‘flights.csv’ THEN ‘1’ ELSE ‘2’ END

3.3. Create a Route location

We are applying the same logic as in 2.2. paragraph, we need to create a route location.

  • Go to the ‘Table Name’ column— click on ‘Create Calculated Field’
  • Use the following function IF [Table Name] = ‘flights.csv’ THEN ‘Origin Airport’ ELSE ‘Destination Airport’ END

STEP 4. Create a JOIN between tables

  • Drag airports.csv to your panel
Creation of JOIN using a calculated field
  • Click ‘Calculated field’ from the drop-down menu to choose a data source.
  • Use the following function IF [Table Name] = ‘flights.csv’ THEN ‘Origin Airport’ ELSE ‘Destination Airport’ END.
  • Choose Iata Code as a dimension from the Airports.csv side. Iata Codes the special three letters codes used in the aviation industry to mark airports and airfields, airlines, and aircraft types. You can use ‘Airport’ instead of ‘Iata Code’ as well.
JOIN function in Tableau using Calculated field

So, JOIN has been created. We’ve covered the most time-consuming and challenging part of flight path map creation.

I am not going to dive deep into the issues of data visualization — that’s easy. In a nutshell, you create a map, then drag ‘Route identifier’ into Detail and ‘Route Location’ in Path mark. That’s all, and then you can play with the functions as you want, depending on the goal — if you wish to show route locations, or specific routes, or filter by states/airlines, etc.

--

--

--

Data Scientists must think like an artist when finding a solution when creating a piece of code. ⚪️ Artists enjoy working on interesting problems, even if there is no obvious answer ⚪️ linktr.ee/mlearning 🔵 Follow to join our 18K+ Unique DAILY Readers 🟠

Recommended from Medium

Steps to be followed in Exploratory Data Analysis.

#13 of 100Scenarios — The 2016/17 edition of the Global Trends

Data Science Roles in the Pharmaceutical and Biotechnology Industries

A case study on eating behavior in China: Combining survey results with Big Data

How to become Data Scientist

Somebody Will Be Last at Medical School: The Case for AI in Healthcare

Healthcare and AI

Flatiron Data Science Module 2 Project

Linear Algebra for Data Science Ep 3 — Identity and Inverse Matrices

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ksenia Udovitskaia

Ksenia Udovitskaia

A Munich-based Business Analyst and Data Visualizer

More from Medium

Udacity Data Visualization Nanodegree: Capstone Project

Data Visualization : The Rise and Fall of Social Technologies

Top Python Libraries for Data Science in 2022

NYC Taxi Trips challenge