Drawing flight routes with NetworkX
In this recipe, we load and visualize a dataset containing many flight routes and airports around the world (obtained from the OpenFlights website at https://openflights.org/data.html).
To draw the graph on a map, you need Cartopy, available at http://scitools.org.uk/cartopy/. You can install it with
conda install -c conda-forge cartopy.
How to do it...
- Let's import a few packages:
>>> import math import json import numpy as np import pandas as pd import networkx as nx import cartopy.crs as ccrs import matplotlib.pyplot as plt from IPython.display import Image %matplotlib inline
- We load the first dataset containing many flight routes:
>>> names = ('airline,airline_id,' 'source,source_id,' 'dest,dest_id,' ...