Skip to content

Commit

Permalink
rerun hqta and do ArcGIS steps
Browse files Browse the repository at this point in the history
  • Loading branch information
edasmalchi committed Dec 20, 2024
1 parent 5a0218e commit 62cd4ae
Show file tree
Hide file tree
Showing 10 changed files with 308 additions and 639 deletions.
43 changes: 28 additions & 15 deletions high_quality_transit_areas/09_enforce_collinearity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@
},
"outputs": [],
"source": [
"feed_names_filtered = feed_names >> filter(_.name.str.contains('Sac'))\n",
"feed_names_filtered = feed_names >> filter(_.name.str.contains('VTA'))\n",
"display(feed_names_filtered)\n",
"gtfs_dataset_key = feed_names_filtered.gtfs_dataset_key.iloc[0]"
]
Expand Down Expand Up @@ -831,7 +831,7 @@
"metadata": {},
"outputs": [],
"source": [
"m # 8 threshold"
"# m # 8 threshold"
]
},
{
Expand Down Expand Up @@ -1024,7 +1024,8 @@
"metadata": {},
"outputs": [],
"source": [
"one_pts = hqta_points >> filter(_.agency_primary.str.contains('Valley'))"
"# one_pts = hqta_points >> filter(_.agency_primary.str.contains('Los Angeles County'))\n",
"one_pts = hqta_points >> filter(_.hqta_details != 'corridor_other_stop')"
]
},
{
Expand Down Expand Up @@ -1068,42 +1069,44 @@
]
},
{
"cell_type": "markdown",
"id": "4b351da3-4825-4caa-8333-33386db868f1",
"cell_type": "code",
"execution_count": null,
"id": "55307463-952c-4595-98d7-a5619096aff3",
"metadata": {},
"outputs": [],
"source": [
"## all bus"
"all_bus = gpd.read_parquet(f\"{GCS_FILE_PATH}all_bus.parquet\")\n",
"# hqta_segments = gpd.read_parquet(f\"{GCS_FILE_PATH}hqta_segments.parquet\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "55307463-952c-4595-98d7-a5619096aff3",
"id": "b9067d6c-df86-4c38-846f-c5de30828293",
"metadata": {},
"outputs": [],
"source": [
"# all_bus = gpd.read_parquet(f\"{GCS_FILE_PATH}all_bus.parquet\")\n",
"hqta_segments = gpd.read_parquet(f\"{GCS_FILE_PATH}hqta_segments.parquet\")"
"from sjoin_stops_to_segments import find_inconclusive_directions"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b9067d6c-df86-4c38-846f-c5de30828293",
"id": "4785bd05-eda6-4139-b801-951f7513d0df",
"metadata": {},
"outputs": [],
"source": [
"from sjoin_stops_to_segments import find_inconclusive_directions"
"# hqta_segments = find_inconclusive_directions(hqta_segments)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4785bd05-eda6-4139-b801-951f7513d0df",
"id": "53421714-f669-4413-8192-b658bc5af47c",
"metadata": {},
"outputs": [],
"source": [
"hqta_segments = find_inconclusive_directions(hqta_segments)"
"# hqta_segments"
]
},
{
Expand All @@ -1113,7 +1116,7 @@
"metadata": {},
"outputs": [],
"source": [
"# one = hqta_segments >> filter(_.schedule_gtfs_dataset_key == '70c8a8b71c815224299523bf2115924a')"
"one = all_bus >> filter(_.schedule_gtfs_dataset_key == 'fb467982dcc77a7f9199bebe709bb700')"
]
},
{
Expand All @@ -1123,7 +1126,7 @@
"metadata": {},
"outputs": [],
"source": [
"# one.geometry = one.buffer(35)"
"one.geometry = one.buffer(35)"
]
},
{
Expand All @@ -1136,6 +1139,16 @@
"# one = one >> filter(_.route_id.isin(['228', '227', '062', '061', '056', '106']))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "56688d44-b377-4b74-8a32-d7f2d2dff3db",
"metadata": {},
"outputs": [],
"source": [
"one.explore(column='segment_direction')"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
8 changes: 4 additions & 4 deletions high_quality_transit_areas/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
hqta_data:
python rail_ferry_brt_stops.py
python create_hqta_segments.py
python create_aggregate_stop_frequencies.py
python sjoin_stops_to_segments.py
# python rail_ferry_brt_stops.py
# python create_hqta_segments.py
# python create_aggregate_stop_frequencies.py
# python sjoin_stops_to_segments.py
python prep_pairwise_intersections.py
python get_intersections.py
python create_bus_hqta_types.py
Expand Down
5 changes: 5 additions & 0 deletions high_quality_transit_areas/logs/hqta_processing.log
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,8 @@
2024-12-17 15:09:48.649 | INFO | __main__:<module>:175 - C3_create_bus_hqta_types 2024-12-11 execution time: 0:00:11.784740
2024-12-17 15:10:23.397 | INFO | __main__:<module>:219 - D1_assemble_hqta_points 2024-12-11 execution time: 0:00:18.075380
2024-12-17 15:10:53.886 | INFO | __main__:<module>:168 - D2_assemble_hqta_polygons 2024-12-11 execution time: 0:00:13.604352
2024-12-19 14:06:19.225 | INFO | __main__:<module>:149 - C1_prep_pairwise_intersections 2024-12-11 execution time: 0:00:04.821081
2024-12-19 14:06:46.848 | INFO | __main__:<module>:124 - C2_find_intersections 2024-12-11 execution time: 0:00:06.916373
2024-12-19 14:07:17.276 | INFO | __main__:<module>:175 - C3_create_bus_hqta_types 2024-12-11 execution time: 0:00:13.000987
2024-12-19 14:07:53.167 | INFO | __main__:<module>:219 - D1_assemble_hqta_points 2024-12-11 execution time: 0:00:18.462037
2024-12-19 14:08:28.603 | INFO | __main__:<module>:168 - D2_assemble_hqta_polygons 2024-12-11 execution time: 0:00:17.899141
9 changes: 7 additions & 2 deletions high_quality_transit_areas/prep_pairwise_intersections.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,27 @@ def sjoin_against_other_operators(
"""
Spatial join of the in group vs the out group.
This could be the operator vs other operators,
or a route vs other routes.
or a route vs other routes. This is currently
east-west vs north-south segments, which requires
the additional step of excluding intersections
resulting from the same route changing direction.
Create a crosswalk / pairwise table showing these links.
Compile all of them, because finding intersections is
computationally expensive,
so we want to do it on fewer rows.
"""
route_cols = ["hqta_segment_id", "segment_direction"]
route_cols = ["hqta_segment_id", "segment_direction", "route_key"]

s1 = gpd.sjoin(
in_group_df[route_cols + ["geometry"]],
out_group_df[route_cols + ["geometry"]],
how = "inner",
predicate = "intersects"
).drop(columns = ["index_right", "geometry"])

s1 = s1[s1["route_key_left"] != s1["route_key_right"]]

route_pairs = (
s1.rename(
Expand Down
Loading

0 comments on commit 62cd4ae

Please sign in to comment.