O'Reilly logo

IPython Interactive Computing and Visualization Cookbook - Second Edition by Cyrille Rossant

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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).

Getting ready

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...

  1. 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
  2. We load the first dataset containing many flight routes:
    >>> names = ('airline,airline_id,' 'source,source_id,' 'dest,dest_id,' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required