Tutorial
Flight data visualization with Tableau is easier than you think. So let's get it rolling and connect Tableau with some data.
The idea behind this flight data tutorial is to show we can use the NOW()
calculation to actually display the completion of the flow. So let's get started !
This Tableau tutorial can be applied to any data set with the following properties:
This basically means that we don't nessecarily have to visualize flight data, but could technically use any other location based data source.
One last thing you need to know is that, for Tableau to be able to map a point A to point B route, it needs to have the starting point and the arrival point in two different rows. This point was illustrated very clearly by Sophie Sparkes in this previous blog post.
If your data set already contains the departure and arrival coordinates in two columns (instead of four), while another column indicates which is which (example: departures are identified by a 0, arrivals by a 1), then you're good to go. Otherwise, you will need to apply a LEFT JOIN to your data in order to duplicate the rows and get one row of the data for the starting point and the other row for the ending point.
If you take a look at my data you'll see in green the fields that are required for my viz and in orange I have highlighted a column JOIN filled with 1s, which is used as the key to join the fields from a secondary sheet in Excel containing the 2 below columns and rows only. This virtually recreates a data set where I indicate my departures and my arrivals with 0 and 1 respectively.
Finally, it can be useful to have a unique identifier for each trip. At the end of this Tableau tutorial you will see I use the ticket number on details to make sure each path is not an aggregation of many trips.
Now that you prepared your flight data, just connect with Tableau and apply the join if it hasn't been done already!
This is what your data should look like (notice how each row is now doubled with the Path column on the right).
First you want to display the flights that are ongoing at this very moment. For this purpose, just create the following calculated field using the NOW() Tableau built-in function:
NOW() > [DEPARTURE DATETIME] AND NOW() < [ARRIVAL DATETIME]
Bring this calculated field to the Filters shelf and set it to True. Only the flights currently in the air will be shown.
Then you want to calculate the completion of the displacement from point A to point B. We'll infer the completion from the departure and arrival times:
(NOW() - [DEPARTURE DATETIME]) / ([ARRIVAL DATETIME] - [DEPARTURE DATETIME])
You can set the default Number Property of the Completion field to percentage if you want to.
Finally, you'll map the current position of each flight applying the completion calculation to a straight line between the departure and arrival point. To do that, we'll create two calculated fields named Lat and Lon as follow:
IIF(
[PATH] = 0,
[DEPARTURE LATITUDE],
([ARRIVAL LATITUDE] - [DEPARTURE LATITUDE]) * [COMPLETION] + [DEPARTURE LATITUDE]
)
and
IIF( [PATH] = 0,
[DEPARTURE LONGITUDE],
([ARRIVAL LONGITUDE] - [DEPARTURE LONGITUDE]) * [COMPLETION] + [DEPARTURE LONGITUDE]
)
Don't forget to set their geographic role to latitude and longitude respectively!
And this is it for the calculation!
Drag and drop Lat to Rows and Lon to Columns, and in the top menu bar go to Analysis and uncheck Aggregate Measures. You should get something like this:
Next, I enlarge the size of my points and I put another Lon calculation to columns along with another Lat calculation to rows. What we want to do is display them on top of each other by selecting the dual axis option for both as follows:
Now, you want to change one of the marks to line and add the Path column to the Path mark for the lines (cf. left screen capture below). Add the Path column to Size for the circles (cf. right screen capture below). You can then aggregate your data using any field that is relevant to your viz by drag and dropping it on detail or color. In my case I use the flight order number.
This is how your flight data visualization should look like:
Great ! We now can see where the flights come from and where they are going! If you want, you can always replace the NOW() calculation by a parameter if you want to give your users the possibility to look at what your flows looked like in the past. In the end, it is up to you to choose what you want to do with this technique!
There are a couple improvements we can make to this viz though. For instance, we could draw a plane/car/train/whatever instead of a basic circle. Also, the path is currently straight, and we could want it to follow the curvature of the earth.
This is the subject this advanced flight data visualization tutorial in which we will implement these improvements: Advanced flight data visualization
New to Ponychart?