The osmnx library combines Open Street Map (OSM) and the powerful NetworkX library to manage street networks used for routing. This library has dozens of dependencies which it rolls up to do all of the complex steps of downloading, analyzing, and visualizing street networks.
You can try to install osmnx using pip:
pip install osmnx
However, you may run into some installation issues due to the dependencies. In that case, it's easier to use the Conda system, which we'll introduce later in this chapter.
The following example uses osmnx to download street data from OSM for a city, creates a street network from it, and calculates some basic statistics:
>>> import osmnx as ox
>>> G = ox.graph_from_place('Bay Saint Louis, MS , USA', network_type='drive')
>>> stats = ox.basic_stats(G)
>>> stats["street_length_avg...