I'm trying to do traffic flow simulation visualization using OSMnx to extract data from OpenStreetMaps using Python. I'm trying to do macroscopic traffic simulation regarding to agent-based congestion analysis. I tried the below code to find the shortest path and it works well.
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)
But for traffic jam or congestion analysis I didn't find any documentation on how to include synthetic congestion data into OSMnx, like inserting more cars and visualize the simulation results using OSMnx maps in Python. Any help is appreciated, Thanks,