Create a graph from OSM within some bounding box.
# OSMnx: New Methods for Acquiring, Constructing, Analyzing, and Visualizing Complex Street Networks
import osmnx as ox
ox.config(use_cache=True, log_console=False)
ox.__version__
'1.1.2'
north, south, east, west = 37.79, 37.78, -122.41, -122.43 # San Francisco
network_type = 'all_private' # "all_private", "all", "bike", "drive", "drive_service", "walk"
# Create a graph from OSM within some bounding box.
G = ox.graph_from_bbox(
north, south, east, west,
network_type=network_type,
simplify=True,
retain_all=False,
truncate_by_edge=False,
clean_periphery=True,
custom_filter=None)
# Plot a graph.
fig, ax = ox.plot_graph(G)
north, south, east, west = 37.79, 37.78, -122.41, -122.43 # San Francisco
network_type = 'all' # "all_private", "all", "bike", "drive", "drive_service", "walk"
# Create a graph from OSM within some bounding box.
G2 = ox.graph_from_bbox(
north, south, east, west,
network_type=network_type,
simplify=True,
retain_all=False,
truncate_by_edge=False,
clean_periphery=True,
custom_filter=None)
# Plot a graph.
fig, ax = ox.plot_graph(G2)
north, south, east, west = 37.79, 37.78, -122.41, -122.43 # San Francisco
network_type = 'bike' # "all_private", "all", "bike", "drive", "drive_service", "walk"
# Create a graph from OSM within some bounding box.
G3 = ox.graph_from_bbox(
north, south, east, west,
network_type=network_type,
simplify=True,
retain_all=False,
truncate_by_edge=False,
clean_periphery=True,
custom_filter=None)
# Plot a graph.
fig, ax = ox.plot_graph(G3)
north, south, east, west = 37.79, 37.78, -122.41, -122.43 # San Francisco
network_type = 'drive' # "all_private", "all", "bike", "drive", "drive_service", "walk"
# Create a graph from OSM within some bounding box.
G4 = ox.graph_from_bbox(
north, south, east, west,
network_type=network_type,
simplify=True,
retain_all=False,
truncate_by_edge=False,
clean_periphery=True,
custom_filter=None)
# Plot a graph.
fig, ax = ox.plot_graph(G4)
north, south, east, west = 37.79, 37.78, -122.41, -122.43 # San Francisco
network_type = 'drive_service' # "all_private", "all", "bike", "drive", "drive_service", "walk"
# Create a graph from OSM within some bounding box.
G5 = ox.graph_from_bbox(
north, south, east, west,
network_type=network_type,
simplify=True,
retain_all=False,
truncate_by_edge=False,
clean_periphery=True,
custom_filter=None)
# Plot a graph.
fig, ax = ox.plot_graph(G5)
north, south, east, west = 37.79, 37.78, -122.41, -122.43 # San Francisco
network_type = 'walk' # "all_private", "all", "bike", "drive", "drive_service", "walk"
# Create a graph from OSM within some bounding box.
G6 = ox.graph_from_bbox(
north, south, east, west,
network_type=network_type,
simplify=True,
retain_all=False,
truncate_by_edge=False,
clean_periphery=True,
custom_filter=None)
# Plot a graph.
fig, ax = ox.plot_graph(G6)