liveBook · Manning

OSMnx

As explained in Optimization Algorithms: AI techniques for design, planning, and control problems

OSMnx is a Python library for retrieving, modeling, and manipulating street-network data from OpenStreetMap.

OSMnx is a Python library for retrieving, modeling, and manipulating street-network data from OpenStreetMap. It downloads filtered geographic data and returns it as a NetworkX graph. section 3.1

Model a road network with:

  • Nodes for intersections, landmarks, or points of interest. section 3.1
  • Directed edges for roads and traffic flow, with attributes such as length, speed limit, and capacity. section 3.1
  • Routes as sequences of edges connecting an origin to a destination. section 3.1

University of Toronto

Set place_name to "University of Toronto", call ox.graph_from_address(place_name), and plot the resulting campus road network. Add geographic context with folium, including street names, neighborhoods, building footprints, and marked locations. section 3.1

Listing 3.7 University of Toronto example
import osmnx as ox
import matplotlib.pyplot as plt
 
place_name = "University of Toronto"     
 
graph = ox.graph_from_address(place_name)   #1
ox.plot_graph(graph,figsize=(10,10))

Inspect the complete Python example for retrieving and plotting the University of Toronto street network. section 3.1

How Optimization Algorithms: AI techniques for design, planning, and control problems covers it

How deep it goes
Defines network representation and demonstrates retrieval and plotting, but does not detail OSM data-fetching internals.
Examples
Uses the University of Toronto campus, its road network, and folium markers for origin, destination, and points of interest.
What it assumes
Builds on basic graph concepts including nodes, edges, directed graphs, and routes.
What you can do after
Apply OSMnx and folium to download, represent, plot, and annotate a place-based street network.
How it connects
Connects OpenStreetMap data with NetworkX graphs, road networks, routes, geographic features, and folium maps.

This explainer was generated by Manning's knowledge graph from the text of Optimization Algorithms: AI techniques for design, planning, and control problems. The section links point to the parts of the book it draws on.