【发布时间】:2022-11-08 04:11:30
【问题描述】:
我正在尝试使用 OSMnx 进行交通流模拟可视化,以使用 Python 从 OpenStreetMaps 中提取数据。我正在尝试对基于代理的拥塞分析进行宏观交通模拟。 我尝试了以下代码以找到最短路径,并且效果很好。
import osmnx as ox
import networkx as nx
ox.config(log_console=True, use_cache=True)
# define the start and end locations in latlng
start_latlng = (37.78497,-122.43327)
end_latlng = (37.78071,-122.41445)
# location where you want to find your route
place = 'San Francisco, California, United States'
# find shortest route based on the mode of travel
mode = 'walk' # 'drive', 'bike', 'walk'
# find shortest path based on distance or time
optimizer = 'time' # 'length','time'
# create graph from OSM within the boundaries of some
# geocodable place(s)
graph = ox.graph_from_place(place, network_type = mode)
# find the nearest node to the start location
orig_node = ox.get_nearest_node(graph, start_latlng)
# find the nearest node to the end location
dest_node = ox.get_nearest_node(graph, end_latlng)
# find the shortest path
shortest_route = nx.shortest_path(graph,
orig_node,
dest_node,
weight=optimizer)
但是对于交通拥堵或拥堵分析,我没有找到任何有关如何将合成拥塞数据包含到 OSMnx 中的文档,例如插入更多汽车并使用 Python 中的 OSMnx 地图可视化模拟结果。 任何帮助表示赞赏, 谢谢,
【问题讨论】:
标签: python openstreetmap osmnx traffic-simulation