我想在osmnx的帮助下找到几个点之间的最短路径。我使用以下代码。但它的产出只有一点。 有人知道为什么吗
import osmnx as ox
place_name = "Hamedan"
graph = ox.graph_from_place(place_name, network_type='drive')
#graph_proj = ox.projection.project_graph(graph, to_crs='epsg:32639')
lats = [34.84008, 34.81894, 34.81746, 34.78828, 34.77877, 34.76029, 34.77038, 34.79837, 34.80043, 34.80108]
lngs = [48.54952, 48.54635, 48.51784, 48.50858, 48.51648, 48.53305, 48.50420, 48.51442, 48.50549, 48.48361]
point_list = [(lng, lat) for lng, lat in zip(lats, lngs)]
nearest_nodes = [ox.distance.nearest_nodes(graph, geographic_coordinates[0], geographic_coordinates[1], return_dist=False) for geographic_coordinates in point_list]
routes = [ox.distance.shortest_path(graph,nearest_nodes[i], nearest_nodes[i+1], weight='length', cpus=1) for i in range(len(nearest_nodes)-1)]
fig, ax = ox.plot.plot_graph_routes(graph,routes,
ax=None,
figsize=(8, 8),
bgcolor="#111111",
node_color="w",
node_size=15,
node_alpha=None,
node_edgecolor="none",
node_zorder=1,
edge_color="#999999",
edge_linewidth=1,
edge_alpha=None,
show=True,
close=False,
save=False,
filepath=None,
dpi=300,
bbox=None)
目前没有回答
相关问题 更多 >
编程相关推荐