OSMnx route_to_gdf 函数
我有一个关于'weight'参数在route_to_gdf函数中使用的问题。在这个链接上说:“weight(字符串)——如果两个节点之间有平行的边,选择权重最低的那条。”
基于这个说明,我对OSMnx的示例有一些疑问,具体在这个链接中:
# calculate two routes by minimizing travel distance vs travel time
orig = list(G)[1]
dest = list(G)[120]
route1 = ox.shortest_path(G, orig, dest, weight="length")
route2 = ox.shortest_path(G, orig, dest, weight="travel_time")
# compare the two routes
route1_length = int(sum(ox.utils_graph.route_to_gdf(G, route1, "length")["length"]))
route2_length = int(sum(ox.utils_graph.route_to_gdf(G, route2, "length")["length"]))
route1_time = int(sum(ox.utils_graph.route_to_gdf(G, route1, "travel_time")["travel_time"]))
route2_time = int(sum(ox.utils_graph.route_to_gdf(G, route2, "travel_time")["travel_time"]))
print("Route 1 is", route1_length, "meters and takes", route1_time, "seconds.")
print("Route 2 is", route2_length, "meters and takes", route2_time, "seconds.")
我觉得代码应该是这样的:
#Since route 2 is minimizing travel time, one should pick the edge that minimizes travel time if there are parallel edges, and then use the routes to compute minimum distance.
route2_length = int(sum(ox.utils_graph.route_to_gdf(G, route2, "travel_time")["length"]))
#Since route 1 is minimizing distance, one should pick the edge that minimizes length if there are parallel edges, and then use the routes to compute minimum travel time.
route1_time = int(sum(ox.utils_graph.route_to_gdf(G, route1, "length")["travel_time"]))
如果我错了,我很抱歉,但我期待听到你的看法。谢谢。
0 个回答
暂无回答