【发布时间】:2020-09-12 00:15:32
【问题描述】:
我正在尝试将路由保存到我使用 OSMNX 绘制的磁盘。 生成的路线遵循道路路径,但是,当我尝试将路径转换为可以轻松保存到磁盘的 LineString 时,路线会以不遵循道路的方式更改,您可以在两个图像之间进行比较。
ORIGIN_point = (13.013206, 77.670987)
DESTINATION_point= (12.821339, 77.678500)
G = ox.graph_from_point(ORIGIN_point, distance=10000, distance_type='network', network_type='drive')
ORIGIN_node = ox.get_nearest_node(G, ORIGIN_point)
DESTINATION_node = ox.get_nearest_node(G, DESTINATION_point)
# find the route between these nodes then plot it
route = nx.shortest_path(G, ORIGIN_node, DESTINATION_node, weight='length')
This route is plotted using osmnx for shortest path IMAGE-1
from shapely.geometry import LineString, Point
graph_proj = ox.project_graph(G)
nodes_proj, edges_proj = ox.graph_to_gdfs(graph_proj, nodes=True, edges=True)
route_nodes = nodes_proj.loc[route]
# Create a geometry for the shortest path
route_line = LineString(list(route_nodes.geometry.values))
route is now converted to lineStringIMAGE-2
我想在 shapefile 中保存到磁盘的路线,请帮帮我。
【问题讨论】: