Being a fairly regular JetBlue customer - they don’t fly everywhere but do most major cities across the US - I have come to enjoy checking out the back-of-the-seat heads up display of flight tracking. For a while they were using Google Maps but that display now uses OpenStreetMap as a basemap.
Ever since I started seeing wifi on JetBlue flights, via FlyFi, I also enjoyed looking at that flight tracker as well. If you are on a JetBlue flight go to http://www.flyfi.com/travel/ (this link won’t work if not currently on a JetBlue flight). FlyFi uses Google for mapping but hopefully they will transition to OpenStreetMap.
FlyFi flight tracker
I then worked with this IPython notebook file which I’ll convert using a method I learned from an earlier blogpost Using IPython Notebook with Pandas and exporting to Markdown
IPython nbconvert jetblue-latlng.ipynb --to markdown
The IPython notebook code:
Import the modules
# Import pandas import pandas as pd # Import matplotlib and Basemap import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap # Set iPython to display visualization inline %matplotlib inline
Read the lat,lng’s and format
inCSV = 'jetblue-gps.csv' df = pd.read_csv(inCSV, header=None) df.columns = ['lat_work','lng_work','drop'] df['latitude'] = df['lat_work'].str.replace('(','').str.replace('new google.maps.LatLng','') df['longitude'] = df['lng_work'].str.replace(')','') df['latitude'] = df['latitude'].astype(float) df['longitude'] = df['longitude'].astype(float) df = df[['latitude','longitude']] df.head(5)
Make the plot with Chris Albon’s Plot Points On A Map blogpost
# Create a figure of size (i.e. pretty big) fig = plt.figure(figsize=(20,10)) # Create a map, using the Gall–Peters projection, map = Basemap(projection='gall', # with low resolution, resolution = 'l', # And threshold 100000 area_thresh = 100000.0, # Centered at 0,0 (i.e null island) lat_0=35, lon_0=-85) # Draw the coastlines on the map map.drawcoastlines() # Draw country borders on the map map.drawcountries() # Fill the land with grey map.fillcontinents(color = '#888888') # Draw the map boundaries map.drawmapboundary(fill_color='#f4f4f4') # Define our longitude and latitude points # We have to use .values because of a wierd bug when passing pandas data # to basemap. x,y = map(df['longitude'].values, df['latitude'].values) # Plot them using round markers of size 6 map.plot(x, y, 'ro', markersize=6) # Show the map plt.show()
The points plotted