Skip to content

Commit

Permalink
noebook to create boardings_by_segment_am.geojson
Browse files Browse the repository at this point in the history
the produced file is used for acceptance criteria summaries
  • Loading branch information
AshishKuls committed Apr 17, 2024
1 parent 1b94fa2 commit b23ad8a
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions notebooks/create-boardings-by-segment-am-geojson.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"#import openmatrix as omx\n",
"import pandas as pd\n",
"import numpy as np\n",
"import geopandas as gpd\n",
"import os\n",
"import json\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Scenario 12 is AM period \n",
"# emme_tsegs.shp files are exported manually from EMME for time periods. \n",
"# transit_segments.csv is also exported manually from EMME. Added \"caps\" and \"capt\" fields to the data table before exporting. \n",
"\n",
"data_dir = \"V:\\\\projects\\\\MTC\\\\transit_path_builder_calib\\\\TM2.2.1.1\\\\output_summaries\\\\Scenario_12\"\n",
"segment_shp = gpd.read_file(os.path.join(data_dir, \"emme_tsegs.shp\"))\n",
"cap_df = pd.read_csv(os.path.join(data_dir, \"transit_segments.csv\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cap_df = cap_df [[\"Line\", \"From\", \"To\", \"capt\", \"caps\"]]\n",
"segment_shp = segment_shp[[\"SEG_ID\", \"LINE_ID\", \"INODE\", \"JNODE\", \"VOLTR\", \"geometry\"]]\n",
"out_df = segment_shp.merge(cap_df, left_on=[\"LINE_ID\", \"INODE\", \"JNODE\"], right_on = [\"Line\", \"From\", \"To\"], how=\"left\")\n",
"out_df = out_df.drop_duplicates(subset=['SEG_ID'])\n",
"out_df = out_df [[\"LINE_ID\", \"INODE\", \"JNODE\",\"VOLTR\", \"caps\", \"capt\", \"geometry\"]]\n",
"out_df.to_file(os.path.join(data_dir, \"boardings_by_segment_am.geojson\"), driver='GeoJSON')\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.7.6 ('tm2py_acceptance')",
"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.7.6"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "79c5570345f898d1e567408541a5b012def5e8a07e15510a7e9419fb9933423e"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit b23ad8a

Please sign in to comment.