plot_route_folium¶

Plot a route as an interactive Leaflet web map.

In [ ]:
# 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__
Out[ ]:
'1.1.2'
In [ ]:
center_point = (37.5661, 126.9783) # (lat, lng) Seoul, South Korea
dist = 1000
dist_type = 'bbox' # "network", "bbox"
network_type = 'all_private' # "all_private", "all", "bike", "drive", "drive_service", "walk"

# Create a graph from OSM within some distance of some (lat, lng) point.
G = ox.graph_from_point(
    center_point,
    dist=dist, 
    dist_type=dist_type,
    network_type=network_type,
    simplify=True, 
    retain_all=False, 
    truncate_by_edge=False, 
    clean_periphery=True, 
    custom_filter=None)

# Set origin and destination node ID
orig, dest = list(G)[0], list(G)[-1]

# Solve shortest path from origin node(s) to destination node(s).
route = ox.distance.shortest_path(G, orig, dest, weight='length', cpus=1)
In [ ]:
# Plot a route as an interactive Leaflet web map.
ox.folium.plot_route_folium(
    G, 
    route, 
    route_map=None, 
    popup_attribute=None, 
    tiles='cartodbpositron', 
    zoom=1, 
    fit_bounds=True, 
    route_color=None, 
    route_width=None, 
    route_opacity=None
)
Out[ ]:
Make this Notebook Trusted to load map: File -> Trust Notebook