"
OSMnx is a Python 2+3 package that lets you download spatial geometries and construct, project, visualize,
and analyze street networks from OpenStreetMap's APIs. Users can download and construct walkable, drivable, or bikable
urban networks with a single line of Python code, and then easily analyze and visualize them.
In a couple lines of code you can examine intersection density, network circuity, average block size, PageRank,
betweenness centrality, connectivity, spatial distribution of dead-ends or 4-way intersections, etc for anywhere in the world.
You can just as easily download and work with building footprints, elevation data, and network routing.
OSMnx lets you download street network data and build topologically corrected street networks, project to UTM and plot the
networks, and save the street network as SVGs, GraphML files, or shapefiles for later use. The street networks are
directed and preserve one-way directionality. API responses are cached locally so OSMnx doesn't have to request the same
data from the API multiple times, saving bandwidth and increasing speed.
You can download a street network by providing OSMnx any of the following (demonstrated in the examples below):
- a bounding box
- a lat-long point plus a distance (either distance along the network, or cardinal)
- an address plus a distance (either distance along the network, or cardinal)
- a place name or list of place names (for OSMnx to automatically geocode and get the boundary of)
- a polygon of the desired street network's boundaries
You can also specify several different network types:
drive
- get drivable public streets (but not service roads)
drive_service
- get drivable streets, including service roads
walk
- get all streets and paths that pedestrians can use (this network type ignores one-way directionality)
bike
- get all streets and paths that cyclists can use
all
- download all non-private OSM streets and paths
all_private
- download all OSM streets and paths, including private-access ones
For example, to download, construct, project, and plot Manhattan's drivable street network:
G = ox.graph_from_place('Manhattan, New York, USA', network_type='drive')
ox.plot_graph(ox.project_graph(G))
For an in-depth demonstration of creating street networks, see
this notebook."
https://github.com/gboeing/osmnx/