OSMnx
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 that it rolls up to handle all of the complex steps of downloading, analyzing, and visualizing street networks.
You can install osmnx using pip:
pip install osmnx
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"] 172.1468804611654 Since we’re talking about web-based data sources, let’s look at a great way to create web-based maps next!