OSMnx features demo
Author: Geoff Boeing
Get street networks and other spatial data anywhere in the world from OpenStreetMap then analyze and visualize them.
- Overview of OSMnx
- Documentation and install instructions
- Examples, demos, tutorials
- Journal article and citation info
This notebook provides a quick tour of some of OSMnx's key features including how to:
- download/model street networks
- calculate stats
- visualize centrality
- impute speeds/travel times and calculate shortest paths
- attach and visualize elevation data and edge grades
- download/model other infrastructure types
- download points of interest data
Working with street networks
OSMnx geocodes the query "Piedmont, California, USA" to retrieve the place boundaries of that city from the Nominatim API, retrieves the drivable street network data within those boundaries from the Overpass API, constructs a graph model, then simplifies/corrects its topology such that nodes represent intersections and dead-ends and edges represent the street segments linking them. All of this is discussed in detail in the documentation and these examples.
OSMnx models all networks as NetworkX
MultiDiGraph objects. You can convert to:
- undirected MultiGraphs
- DiGraphs without (possible) parallel edges
- GeoPandas node/edge GeoDataFrames
You can create a graph from node/edge GeoDataFrames, as long as gdf_nodes is indexed by osmid and gdf_edges is multi-indexed by u, v, key (following normal MultiDiGraph structure). This allows you to load graph node/edge shapefiles or GeoPackage layers as GeoDataFrames then convert to a MultiDiGraph for graph analytics.
Basic street network stats
stats documentation: https://osmnx.readthedocs.io/en/stable/osmnx.html#module-osmnx.stats
The radius (i.e., minimum eccentricity) of this street network is approximately 2.5 kilometers.
Visualize street centrality
Here we plot the street network and color its edges (streets) by their relative closeness centrality.
Nodes are colored from lowest elevation (dark blue) to highest (bright yellow).
Example: create elevation-based impedance functions to route around hills.
Get networks other ways
make queries less ambiguous to help the geocoder out, if it's not finding what you're looking for
Examples of getting networks by coordinates, bounding box, or any custom polygon shape.
Get other networked infrastructure types
...like rail or electric grids or even the canals of Venice and Amsterdam, using the
custom_filter parameter: see more examples.
Get any geospatial entities' geometries and attributes
geometries module to download entities, such as local amenities, points of interest, or building footprints, and turn them into a GeoDataFrame: see docs. For more usage examples of downloading geospatial objects from OSM, see this notebook.
See the other notebooks for more examples of visualization with OSMnx.