Agent-based Transportaion Model (Washington DC)

[1]:
from pyrosm import OSM, get_data

region = "district-of-columbia"
fp = get_data(region)
osm = OSM(fp)
osm.keep_node_info = True
network = osm.get_network(
    "all",
    extra_attributes=[
        "lanes:forward",
        "lanes:backward",
        "cycleway:left",
        "cycleway:right",
    ],
    nodes=True,
)
Downloaded Protobuf data 'district-of-columbia-latest.osm.pbf' (18.12 MB) to:
'/tmp/pyrosm/district-of-columbia-latest.osm.pbf'
[2]:
network[0].head(1)
[2]:
tags visible changeset lon lat timestamp version id geometry
0 {'highway': 'traffic_signals', 'source': 'surv... False 0 -77.108261 38.935738 1421734870 3 1391829849 POINT (-77.10826 38.93574)
[3]:
network[1].head(1)
[3]:
access area bicycle bridge cycleway est_width foot footway highway junction ... id nodes timestamp version tags osm_type geometry u v length
0 None None None None None None None None residential None ... 4681186 [1391829849, 281072, 3299878446, 3299878455, 2... 1613445127 5 {"visible":false} way LINESTRING (-77.10826 38.93574, -77.10825 38.9... 1391829849 281072 11.048

1 rows × 43 columns

[4]:
graph = osm.to_graph(network[0], network[1], "networkx")
[5]:
graph.nodes[1391829849]
[5]:
{'tags': {'highway': 'traffic_signals', 'source': 'survey'},
 'visible': False,
 'changeset': 0,
 'x': -77.10826110839844,
 'y': 38.93573760986328,
 'timestamp': 1421734870,
 'version': 3,
 'osmid': 1391829849,
 'geometry': <POINT (-77.108 38.936)>}
[6]:
graph.edges[(1391829849, 281072, 0)]
[6]:
{'access': None,
 'area': None,
 'bicycle': None,
 'bridge': None,
 'cycleway': None,
 'est_width': None,
 'foot': None,
 'footway': None,
 'highway': 'residential',
 'junction': None,
 'lanes': None,
 'lit': None,
 'maxspeed': None,
 'motorcar': None,
 'motor_vehicle': None,
 'name': None,
 'oneway': None,
 'overtaking': None,
 'psv': None,
 'ref': None,
 'service': None,
 'segregated': None,
 'sidewalk': None,
 'smoothness': None,
 'surface': None,
 'tracktype': None,
 'tunnel': None,
 'turn': None,
 'width': None,
 'lanes:forward': None,
 'lanes:backward': None,
 'cycleway:left': None,
 'cycleway:right': None,
 'osmid': 4681186,
 'nodes': [1391829849, 281072, 3299878446, 3299878455, 2921446557],
 'timestamp': 1613445127,
 'version': 5,
 'tags': '{"visible":false}',
 'osm_type': 'way',
 'geometry': <LINESTRING (-77.108 38.936, -77.108 38.936)>,
 'u': 1391829849,
 'v': 281072,
 'length': 11.048,
 'key': 0}