def test_routing_folium():
import networkx as nx
with httmock.HTTMock(get_mock_response_content('overpass-response-3.json.gz')):
G = ox.graph_from_address('398 N. Sicily Pl., Chandler, Arizona', distance=800, network_type='drive')
origin = (33.307792, -111.894940)
destination = (33.312994, -111.894998)
origin_node = ox.get_nearest_node(G, origin)
destination_node = ox.get_nearest_node(G, destination)
route = nx.shortest_path(G, origin_node, destination_node)
attributes = ox.get_route_edge_attributes(G, route, 'length')
fig, ax = ox.plot_graph_route(G, route, save=True, filename='route', file_format='png')
fig, ax = ox.plot_graph_route(G, route, origin_point=origin, destination_point=destination,
save=True, filename='route', file_format='png')
graph_map = ox.plot_graph_folium(G, popup_attribute='name')
route_map = ox.plot_route_folium(G, route)
评论列表
文章目录