{ "cells": [ { "cell_type": "markdown", "id": "0f22d444-d81e-4723-a365-1f801d0e93ef", "metadata": {}, "source": [ "# Agent-based Transportaion Model (Washington DC)" ] }, { "cell_type": "code", "execution_count": null, "id": "b699c899-cc00-45ee-8fdf-d25c27d6cf8d", "metadata": {}, "outputs": [], "source": [ "from pyrosm import OSM, get_data\n", "\n", "region = \"district-of-columbia\"\n", "fp = get_data(region)\n", "osm = OSM(fp)\n", "osm.keep_node_info = True\n", "network = osm.get_network(\n", " \"all\",\n", " extra_attributes=[\n", " \"lanes:forward\",\n", " \"lanes:backward\",\n", " \"cycleway:left\",\n", " \"cycleway:right\",\n", " ],\n", " nodes=True,\n", ")" ] }, { "cell_type": "code", "execution_count": null, "id": "6303a366-9570-4edb-8368-5c3b9f90e570", "metadata": {}, "outputs": [], "source": [ "network[0].head(1)" ] }, { "cell_type": "code", "execution_count": null, "id": "4b1c26ef-74ad-46d0-897b-18af0e2cabf5", "metadata": {}, "outputs": [], "source": [ "network[1].head(1)" ] }, { "cell_type": "code", "execution_count": null, "id": "f86f9b5b-4cd4-4304-bcb9-5b07e85fb060", "metadata": {}, "outputs": [], "source": [ "graph = osm.to_graph(network[0], network[1], \"networkx\")" ] }, { "cell_type": "code", "execution_count": null, "id": "791a5229-6299-4a29-b723-2f447a6e5393", "metadata": {}, "outputs": [], "source": [ "graph.nodes[1391829849]" ] }, { "cell_type": "code", "execution_count": null, "id": "2051fc62-b5c8-4b9c-889b-295920efc649", "metadata": {}, "outputs": [], "source": [ "graph.edges[(1391829849, 281072, 0)]" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 5 }