Skip to content

Commit

Permalink
Merge pull request #1318 from cal-itp/speedmaps-patch
Browse files Browse the repository at this point in the history
Speedmaps patch
  • Loading branch information
edasmalchi authored Dec 9, 2024
2 parents 31686c5 + 48ad820 commit cbac204
Show file tree
Hide file tree
Showing 125 changed files with 583 additions and 82 deletions.
3 changes: 2 additions & 1 deletion ca_transit_speed_maps/01_new_speedmaps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"outputs": [],
"source": [
"## parameters cell\n",
"organization_source_record_id = 'recvEBkSBc7UxlarC'"
"\n",
"organization_source_record_id = ''"
]
},
{
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ca_transit_speed_maps/speedmap_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def map_time_period(district_gdf: gpd.GeoDataFrame, speedmap_segs: gpd.GeoDataFr
color_col = {'new_speedmap': 'p20_mph', 'new_speed_variation': 'fast_slow_ratio'}[map_type]
shn_state = map_shn(district_gdf)
display_date = analysis_date.strftime('%B %d %Y (%A)')
filename = f"{analysis_date}_{speedmap_segs.organization_source_record_id.iloc[0]}_{map_type}"
filename = f"{analysis_date}_{speedmap_segs.organization_source_record_id.iloc[0]}_{map_type}_{time_of_day}"
title = f"{speedmap_segs.organization_name.iloc[0]} {display_date} {time_of_day}"

if map_type == 'new_speedmap':
Expand Down
1 change: 1 addition & 0 deletions ca_transit_speed_maps/stage_run_portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def make_rt_site_yml(speedmaps_index_joined,

chapters_list = []
speedmaps_index_joined = speedmaps_index_joined >> arrange(_.caltrans_district)
speedmaps_index_joined = speedmaps_index_joined >> distinct(_.caltrans_district, _.organization_name, _.organization_source_record_id)
for district in speedmaps_index_joined.caltrans_district.unique():
if type(district) == type(None):
continue
Expand Down
66 changes: 66 additions & 0 deletions portfolio/rt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# California Transit Speed Maps

Supporting transit is integral to Caltrans' vision of delivering a connected, equitable, and more sustainable state transportation network as well as the Department’s work to combat the climate crisis.

To help realize that vision, the California Integrated Travel Program (Cal-ITP) is developing analyses alongside our partners such as the Caltrans Division of Research, Innovation and System Information (DRISI) in order to provide Caltrans staff and external stakeholders with actionable data to prioritize transit projects.

Transit in California is overwhelmingly provided by buses. However, speeds have been declining for years, and now average below 10mph across much of California – and often much lower during peak times in urban areas. These slow speeds translate to countless hours wasted for transit riders and jeopardize the ability of California’s transit agencies to provide frequent, reliable service.

We also measure speed variation. Low speeds delay transit, but variation is equally problematic since it leads to an inconsistent experience for transit riders and complicates scheduling of transit services.

Our maps already include routes and operators accounting for about 80% of bus riders in the state, including operators in every Caltrans district. Cal-ITP continues to work daily to onboard and support new agencies in providing quality data that improves the transit rider experience and powers useful and timely analysis.

This site is updated at least quarterly.

Select source code can be found at:

[https://github.com/cal-itp/data-analyses/tree/main/ca_transit_speed_maps](https://github.com/cal-itp/data-analyses/tree/main/ca_transit_speed_maps)

[https://github.com/cal-itp/data-analyses/tree/main/rt_delay/rt_analysis](https://github.com/cal-itp/data-analyses/tree/main/rt_delay/rt_analysis)

[https://github.com/cal-itp/data-analyses/blob/main/_shared_utils/shared_utils/rt_utils.py](https://github.com/cal-itp/data-analyses/blob/main/_shared_utils/shared_utils/rt_utils.py)


## Time Period Definitions

* AM Peak: 07:00-10:00
* Midday: 10:00-15:00
* PM Peak: 15:00-20:00
* Evening: 20:00-24:00
* Owl: 00:00-04:00
* Early AM: 04:00-07:00

## Methodology

Segment speed is estimated using the time and distance between vehicle positions reports, with distance being measured linearly along the corresponding transit route. These maps show speeds along segments, which are calculated by interpolating the two nearest position reports for each trip in order to estimate speed along each segment, then taking the 20th percentile of speeds for that segment in each time period. This site shows data for a specific day, usually a Wednesday (and not a holiday or other date we believe could be atypical).

Generally, segments are constructed from one stop to the next, however, if the distance between stops is large we add interpolated segments every kilometer to provide additional resolution for rural and express services.

We use the ratio between 80th and 20th percentile speeds in a segment to measure speed variation.

## What's New?

We're aligining with segment speeds published via the [open data portal!](https://gis.data.ca.gov/datasets/4937eeb59fdb4e56ae75e64688c7f2c0_0/explore)

While the datasets don't fully match just yet, this site is now based on the same underlying data. This should help us update it more often, enhance accuracy for complex route shapes, and include as many transit operators as possible.

The site also includes a more informative speed and variation by time of day chart at the bottom of the page.

## Data Sources
Archived GTFS-Realtime Vehicle Positions data, plus corresponding GTFS Schedule data.

Each map includes a link to download its geospatial data in a gzip-compressed GeoJSON format (.geojson.gz). Most file compression software, including 7zip on Windows, will decompress these files. Once decompressed, most GIS software including ESRI ArcGIS Pro and QGIS can import the GeoJSON.

## Ongoing Work

The Cal-ITP team is working to transition the site to a rolling average of recent dates, instead of a single day.

Questions or feedback? Please email [email protected]

## Who We Are

This website was created by the [California Department of Transportation](https://dot.ca.gov/)'s Division of Data and Digital Services. We are a group of data analysts and scientists who analyze transportation data, such as General Transit Feed Specification (GTFS) data, or data from funding programs such as the Active Transportation Program. Our goal is to transform messy and indecipherable original datasets into usable, customer-friendly products to better the transportation landscape. For more of our work, visit our [portfolio](https://analysis.calitp.org/).

<img src="https://raw.githubusercontent.com/cal-itp/data-analyses/main/portfolio/Calitp_logo_MAIN.png" alt="Alt text" width="200" height="100"> <img src="https://raw.githubusercontent.com/cal-itp/data-analyses/main/portfolio/CT_logo_Wht_outline.gif" alt="Alt text" width="129" height="100">

<br>Caltrans®, the California Department of Transportation® and the Caltrans logo are registered service marks of the California Department of Transportation and may not be copied, distributed, displayed, reproduced or transmitted in any form without prior written permission from the California Department of Transportation.
43 changes: 43 additions & 0 deletions portfolio/rt/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Book settings
# Learn more at https://jupyterbook.org/customize/config.html

title: California Transit Speed Maps
author: Cal-ITP
copyright: "2024"
#logo: calitp_logo_MAIN.png

# Force re-execution of notebooks on each build.
# See https://jupyterbook.org/content/execute.html
execute:
execute_notebooks: 'off'
allow_errors: false
timeout: -1

# Define the name of the latex output file for PDF builds
latex:
latex_documents:
targetname: book.tex

launch_buttons:
binderhub_url: "https://mybinder.org"
jupyterhub_url: "https://hubtest.k8s.calitp.jarv.us"
thebe: true

repository:
url: https://github.com/cal-itp/data-analyses/ # Online location of your book
# path_to_book: docs # Optional path to your book, relative to the repository root
path_to_book: ca_transit_speed_maps
branch: main # Which branch of the repository should be used when creating links (optional)

# Add GitHub buttons to your book
# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository
html:
use_issues_button: true
use_repository_button: true
use_edit_page_button: true
google_analytics_id: 'G-JCX3Z8JZJC'

sphinx:
config:
html_js_files:
- https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js
41 changes: 41 additions & 0 deletions portfolio/rt/_toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
format: jb-book
parts:
- caption: null
chapters:
- file: district_01-eureka.md
sections:
- glob: district_01-eureka/*
- file: district_02-redding.md
sections:
- glob: district_02-redding/*
- file: district_03-marysville.md
sections:
- glob: district_03-marysville/*
- file: district_04-oakland.md
sections:
- glob: district_04-oakland/*
- file: district_05-san-luis-obispo.md
sections:
- glob: district_05-san-luis-obispo/*
- file: district_06-fresno.md
sections:
- glob: district_06-fresno/*
- file: district_07-los-angeles.md
sections:
- glob: district_07-los-angeles/*
- file: district_08-san-bernardino.md
sections:
- glob: district_08-san-bernardino/*
- file: district_09-bishop.md
sections:
- glob: district_09-bishop/*
- file: district_10-stockton.md
sections:
- glob: district_10-stockton/*
- file: district_11-san-diego.md
sections:
- glob: district_11-san-diego/*
- file: district_12-irvine.md
sections:
- glob: district_12-irvine/*
root: README
1 change: 1 addition & 0 deletions portfolio/rt/district_01-eureka.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# District 01 - Eureka
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
1 change: 1 addition & 0 deletions portfolio/rt/district_02-redding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# District 02 - Redding
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
1 change: 1 addition & 0 deletions portfolio/rt/district_03-marysville.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# District 03 - Marysville
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
1 change: 1 addition & 0 deletions portfolio/rt/district_04-oakland.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# District 04 - Oakland
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
1 change: 1 addition & 0 deletions portfolio/rt/district_05-san-luis-obispo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# District 05 - San Luis Obispo
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Loading

0 comments on commit cbac204

Please sign in to comment.