import pandas as pd
import re
import numpy as np
from IPython.display import display
%matplotlib inline
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator
from matplotlib import rcParams
from functions import *
plt.rcParams.update({'axes.titlepad': 20, 'font.size': 12, 'axes.titlesize':20})
colors = [(0/255,107/255,164/255), (255/255, 128/255, 14/255), 'red', 'green']
airlines = pd.read_csv('./data/airlines.csv')
airports = pd.read_csv('./data/airports.csv')
routes = pd.read_csv('./data/routes.csv')
geo_routes = pd.read_csv('./data/geo_routes.csv')
Variables available:
print("Airlines: ", end='')
for element in airlines.columns:
print("%s | " % element, end='')
print("\nAirports: ", end='')
for element in airports.columns:
print("%s | " % element, end='')
print("\nRoutes: ", end='')
for element in routes.columns:
print("%s | " % element, end='')
print("\nGeo Routes: ", end='')
for element in geo_routes.columns:
print("%s | " % element, end='')
DF snipet:
print("Airlines:")
display(airlines.iloc[:3])
print("Airports:")
display(airports.iloc[:3])
print("Routes:")
display(routes.iloc[:3])
print("Geo Routes:")
display(geo_routes.iloc[:3])
from mpl_toolkits.basemap import Basemap
fig, ax = plt.subplots(figsize=(15,20))
m = Basemap(projection='merc', llcrnrlat=-80, urcrnrlat=80, llcrnrlon=-180, urcrnrlon=180)
x,y = m(airports['longitude'].tolist(), airports['latitude'].tolist())
m.scatter(x, y, s=1)
m.drawcoastlines()
ax.set_title('Scaled Up Earth With Coastlines')
plt.show()
fig, ax = plt.subplots(figsize=(15,20))
m = Basemap(projection='merc', llcrnrlat=-80, urcrnrlat=80, llcrnrlon=-180, urcrnrlon=180)
m.drawcoastlines()
def create_great_circles(input_df):
for idx, row in input_df.iterrows():
#print(row['start_lon'], row['end_lon'], row['start_lat'], row['end_lat'])
if((abs(row['end_lat']-row['start_lat']) < 180) &
(abs(row['end_lon']-row['start_lon']) < 180)):
m.drawgreatcircle(row['start_lon'], row['start_lat'], row['end_lon'], row['end_lat'])
dfw = geo_routes[geo_routes['source']=='DFW']
create_great_circles(dfw)
plt.show()
fig, ax = plt.subplots(figsize=(10,10))
m = Basemap(projection='merc', llcrnrlat=20, urcrnrlat=70, llcrnrlon=-30, urcrnrlon=50, resolution='l')
m.drawcoastlines()
m.fillcontinents(color='#F0E0BB', lake_color='#BBDDF0')
m.drawmapboundary(fill_color='#BBDDF0')
m.drawcountries(linewidth=0.5)
def create_great_circles(input_df):
for idx, row in input_df.iterrows():
#print(row['start_lon'], row['end_lon'], row['start_lat'], row['end_lat'])
if((abs(row['end_lat']-row['start_lat']) < 180) &
(abs(row['end_lon']-row['start_lon']) < 180)):
m.drawgreatcircle(row['start_lon'], row['start_lat'], row['end_lon'], row['end_lat'])
df = geo_routes[geo_routes['source']=='LIS']
european_routes = df[(df['end_lon']>-50) & (df['end_lon']<50) & (df['end_lat']>20) & (df['end_lat']<70)]
create_great_circles(european_routes)
plt.show()