GTFS Segments
GTFS Segments: A Fast and Efficient Library to Generate Bus Stop Spacings - Published in JOSS (2024)
Science Score: 100.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 18 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: sciencedirect.com, joss.theoj.org -
✓Committers with academic emails
1 of 3 committers (33.3%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Keywords from Contributors
Scientific Fields
Repository
GTFS Segments: A fast and efficient library to generate bus stop spacings
Basic Info
- Host: GitHub
- Owner: UTEL-UIUC
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://gtfs-segments.readthedocs.io
- Size: 42.3 MB
Statistics
- Stars: 44
- Watchers: 1
- Forks: 3
- Open Issues: 3
- Releases: 8
Topics
Metadata Files
README.md
Table of Contents
About The Project
The gtfs-segments is a Python (3.9+) package that represents GTFS data for buses in a concise tabular manner using segments. The distribution of bus stop spacings can be viewed by generating histograms. The stop spacings can be visualized at the network, route, or segment level. The segment data can be exported to well-known formats such as .csv or .geojson for further analysis. Additionally, the package provides commands to download the latest data from @mobility data sources.
The package condenses the raw GTFS data by considering the services offered only on the busiest day(in the data). More discussion on the interpretation of different weightings for stop spacings, and the process in which the package condenses information can be seen in our paper. The usage of the package is detailed in documentation. The stop spacings dataset containing over 540 transit providers in the US generated using this package can be found on Harvard Dataverse.
Getting Started
Prerequisites
The major dependencies of this library are the following packages.
|
|
The detailed list of package dependencies can be found in requirements.txt
Installation
Option A
Use pip to install the package.
sh
pip install gtfs-segments
ℹ️ Windows users may have to download and install Microsoft Visual C++ distributions. Follow these instructions.
📓 Google Colab : You can install and use the
gtfs-segmentsvia google colab. Here is a tutorial to help you get started. Make a copy and get started with your work!
Option B
Clone the repo
sh git clone https://github.com/UTEL-UIUC/gtfs_segments.gitInstall geopandas using the following code. Read more here
sh conda create -n geo_env -c conda-forge python=3.11 geopandas conda activate geo_envInstall the
gtfs_segmentspackagesh cd gtfs_segments python setup.py install
Usage
ℹ️ For documentation, please refer to the Documentation
Import the package using
python
import gtfs_segments
Get GTFS Files
Fetch all sources
python
from gtfs_segments import fetch_gtfs_source
sources_df = fetch_gtfs_source()
sources_df.head()
Fetch source by name/provider/state
python
from gtfs_segments import fetch_gtfs_source
sources_df = fetch_gtfs_source(place ='Chicago')
sources_df
Automated Download
python
from gtfs_segments import download_latest_data
download_latest_data(sources_df,"output_folder")
Manual Download
Download the GTFS .zip files from @transitfeeds or @mobility data.
Get GTFS Segments
```python from gtfssegments import getgtfssegments segmentsdf = getgtfssegments("pathtogtfszipfile")
[Optional] Run in parallel using multiple CPU cores
segmentsdf = getgtfssegments("pathtogtfszip_file", parallel = True) ```
Alternatively, filter a specific agency by passing agency_id as a string or multiple agencies as list ["SFMTA",]
segments_df = get_gtfs_segments("path_to_gtfs_zip_file",agency_id = "SFMTA")
segments_df
Table generated by gtfs-segments using data from San Francisco’s Muni system. Each row contains the following columns:
segment_id: the segment's identifier, produced by gtfs-segmentsstop_id1: the identifier of the segment's beginning stop. The identifier is the same one the agency has chosen in the stops.txt file of its GTFS package.stop_id2: The identifier of the segment's ending stop.route_id: The same route ID listed in the agency's routes.txt file.direction_id: The route's direction identifier.traversals: The number of times the indicated route traverses the segment during the "measurement interval." The "measurement interval" chosen is the busiest day in the GTFS schedule: the day which has the most bus services running.distance: The length of the bus segment in meters.geometry: The segment's LINESTRING (a format for encoding geographic paths) written in WGS84 (EPGS:4326) coordinates, that is, unprojected longitude-latitude pairs, as used in GTFS.traversal_time: The time (in seconds) that it takes for the bus to traverse the segment.speed: The speed of the bus (in kmph) while traversing the segment. Default tonp.inf♾ in casetraversal_timeis zero.
Each row does not represent one segment. Rather, each row maps to a combination of a segment, a route that includes that segment, and a direction. For instance, a segment included in eight routes will appear as eight rows, which will have the same information except for route_id and traversals (since some routes might traverse the segment more than others). This choice enables filtering by route and preserves how many times each route traverses each segment during the measurement interval. The direction identifier is used for very rare cases (mostly loops) in which a route visits the same two stops, in the same order, but in different directions.
Visualize Spacings
Visualize stop spacings at network, route and segments levels along with basemaps and stop locations.
ℹ️ For more information on visualization refer to the Visualization Tutorial
ℹ️ Alternatively, use
view_spacings_interactiveto view the stop spacings interactively.
python
from gtfs_segments import view_spacings
view_spacings(segments_df,route = ['8'],segment = ['6364-3725-1'],basemap=True)
Heatmap
View the heatmap of stop spacings ("distance" as metric). Use Diverging colormaps to highlight narrow and wide spacings. Set light_mode = False for Dark mode.
python
from gtfs_segments import view_heatmap
f = view_heatmap(df, cmap='RdBu', light_mode=True)
python
view_heatmap(df, cmap="YlOrRd", interactive=True, light_mode=False)
Plot Distributions
python
from gtfs_segments import plot_hist
plot_hist(segments_df, max_spacing = 1200)
Get Route Summary Stats
python
from gtfs_segments import get_route_stats,get_bus_feed
feed = get_bus_feed('path_to_gtfs.zip')
get_route_stats(feed)
Here each row contains the following columns:
route: Theroute_idfor the route of interestdirection: Thedirection_idof the routeroute_length: The total length of the route.Units: Kilometers (Km)total time: The total scheduled time to travel the whole route.Units: Hours (Hr)headway: The average headway between consecutive buses for the route. ANaNindicates only 1 trip.Units: Hours (Hr)peak_buses: The 15-minute interval where the route has the maximum number of buses concurrently running.average_speed: The average speed of the bus along the route.Units: Kmphn_bus_avg: The average number of buses concurrently runningbus_spacing: The average spacing (in distance) between consecutive buses.Units:Kilometers (Km)stop_spacing: The average distance between two consecutive stops.Units:Kilometers (Km)
Download Segments Data
Download the data as either .csv or .geojson
```python from gtfssegments import exportsegments exportsegments(segmentsdf,'filename', output_format ='geojson')
Get csv without geometry
exportsegments(segmentsdf,'filename', output_format ='csv',geometry = False) ```
Roadmap
- [x] Add interactive visualization with folium
- [x] Log trips that do not have shapes
- [ ] Visualize catchment areas for stops
See the open issues for a full list of proposed features (and known issues).
License
Distributed under the MIT License. See LICENSE.txt for more information.
Citing gtfs-segments
If you use gtfs-segments in your research please use the following BibTeX entry:
bibtex
@article{Devunuri_GTFS_Segments_A_2024,
author = {Devunuri, Saipraneeth and Lehe, Lewis},
doi = {10.21105/joss.06306},
journal = {Journal of Open Source Software},
month = mar,
number = {95},
pages = {6306},
title = {{GTFS Segments: A Fast and Efficient Library to Generate Bus Stop Spacings}},
url = {https://joss.theoj.org/papers/10.21105/joss.06306},
volume = {9},
year = {2024}
}
Alternative: Check the Cite this repository
Citing stop spacings paper
If you use stop spacings paper in your research please use the following BibTeX entry:
bibtex
@article{Devunuri2024,
title = {Bus Stop Spacing Statistics: {{Theory}} and Evidence},
shorttitle = {Bus Stop Spacing Statistics},
author = {Devunuri, Saipraneeth and Lehe, Lewis J. and Qiam, Shirin and Pandey, Ayush and Monzer, Dana},
year = {2024},
month = jan,
journal = {Journal of Public Transportation},
volume = {26},
pages = {100083},
issn = {1077-291X},
doi = {10.1016/j.jpubtr.2024.100083},
url = {https://www.sciencedirect.com/science/article/pii/S1077291X24000031},
urldate = {2024-03-07},
keywords = {Bus stop,GTFS,Public Transit,Stop Spacings,Transit Planning}
}
<!--
Citing stop spacings dataset
If you use the stop spacings dataset in your research please use the following BibTeX entry:
bibtex
@data{DVN/SFBIVU_2022,
author = {Devunuri, Saipraneeth and Shirin Qiam and Lewis Lehe},
publisher = {Harvard Dataverse},
title = {{Bus Stop Spacings for Transit Providers in the US}},
UNF = {UNF:6:zUgB0CGrPL27iqhKd/umRA==},
year = {2022},
version = {V1},
doi = {10.7910/DVN/SFBIVU},
url = {https://doi.org/10.7910/DVN/SFBIVU}
}
-->
Contributing
Contributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
For more information refer to CONTRIBUTING.md
Contact
Saipraneeth Devunuri - @praneethDevunu1 - sd37@illinois.edu
Project Link: https://github.com/UTEL-UIUC/gtfs_segments
Acknowledgments
- Parts of the code use the Partridge library
- Do check out gtfs_functions which was an inspiration for this project
- Shoutout to Mobility Data for compiling GTFS from around the globe and constantly maintaining them
Owner
- Name: UTEL-UIUC
- Login: UTEL-UIUC
- Kind: organization
- Repositories: 4
- Profile: https://github.com/UTEL-UIUC
JOSS Publication
Citation (CITATION.cff)
cff-version: "1.2.0"
authors:
- family-names: Devunuri
given-names: Saipraneeth
orcid: "https://orcid.org/0000-0002-5911-4681"
- family-names: Lehe
given-names: Lewis
orcid: "https://orcid.org/0000-0001-8029-1706"
contact:
- family-names: Devunuri
given-names: Saipraneeth
orcid: "https://orcid.org/0000-0002-5911-4681"
doi: 10.5281/zenodo.10681151
message: If you use this software, please cite our article in the
Journal of Open Source Software.
preferred-citation:
authors:
- family-names: Devunuri
given-names: Saipraneeth
orcid: "https://orcid.org/0000-0002-5911-4681"
- family-names: Lehe
given-names: Lewis
orcid: "https://orcid.org/0000-0001-8029-1706"
date-published: 2024-03-19
doi: 10.21105/joss.06306
issn: 2475-9066
issue: 95
journal: Journal of Open Source Software
publisher:
name: Open Journals
start: 6306
title: "GTFS Segments: A Fast and Efficient Library to Generate Bus
Stop Spacings"
type: article
url: "https://joss.theoj.org/papers/10.21105/joss.06306"
volume: 9
title: "GTFS Segments: A Fast and Efficient Library to Generate Bus Stop
Spacings"
GitHub Events
Total
- Issues event: 4
- Watch event: 13
- Delete event: 2
- Issue comment event: 5
- Push event: 5
- Pull request event: 5
- Create event: 2
Last Year
- Issues event: 4
- Watch event: 13
- Delete event: 2
- Issue comment event: 5
- Push event: 5
- Pull request event: 5
- Create event: 2
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Praneeth Devunuri | s****7@i****u | 198 |
| dependabot[bot] | 4****] | 5 |
| lewis500 | l****0@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 6
- Total pull requests: 13
- Average time to close issues: about 1 month
- Average time to close pull requests: about 8 hours
- Total issue authors: 2
- Total pull request authors: 2
- Average comments per issue: 1.17
- Average comments per pull request: 0.15
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 7
Past Year
- Issues: 4
- Pull requests: 6
- Average time to close issues: 3 days
- Average time to close pull requests: about 5 hours
- Issue authors: 1
- Pull request authors: 2
- Average comments per issue: 1.0
- Average comments per pull request: 0.0
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 4
Top Authors
Issue Authors
- araichev (4)
- praneethd7 (2)
Pull Request Authors
- praneethd7 (9)
- dependabot[bot] (8)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- pypi 258 last-month
-
Total dependent packages: 1
(may contain duplicates) -
Total dependent repositories: 0
(may contain duplicates) - Total versions: 33
- Total maintainers: 1
proxy.golang.org: github.com/utel-uiuc/gtfs_segments
- Documentation: https://pkg.go.dev/github.com/utel-uiuc/gtfs_segments#section-documentation
- License: mit
-
Latest release: v2.1.7+incompatible
published over 1 year ago
Rankings
proxy.golang.org: github.com/UTEL-UIUC/gtfs_segments
- Documentation: https://pkg.go.dev/github.com/UTEL-UIUC/gtfs_segments#section-documentation
- License: mit
-
Latest release: v2.1.7+incompatible
published over 1 year ago
Rankings
pypi.org: gtfs-segments
GTFS Segments: A fast and efficient library to generate bus stop spacings
- Homepage: https://github.com/UTEL-UIUC/gtfs_segments
- Documentation: https://gtfs-segments.readthedocs.io
- License: MIT License Copyright (c) 2023, Saipraneeth Devunuri, Lewis Lehe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
Latest release: 2.1.7
published almost 2 years ago
Rankings
Maintainers (1)
Dependencies
- Shapely ==1.8.2
- contextily ==1.2.0
- geopandas ==0.10.2
- matplotlib ==3.5.1
- numpy ==1.22.2
- pandas ==1.4.1
- partridge ==1.1.1
- requests ==2.27.1
- scipy ==1.8.0
- setuptools ==62.4.0
- utm ==0.7.0
- actions/checkout v3 composite
- actions/upload-artifact v1 composite
- openjournals/openjournals-draft-action master composite
- actions/checkout v3 composite
- actions/setup-python v3 composite
- actions/checkout v3 composite
- actions/setup-python v3 composite
- pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
- mkdocs *
- mkdocs-jupyter *
- mkdocs-material *
- mkdocstrings *
- mkdocstrings-python *
- charset_normalizer *
- contextily *
- faust-cchardet *
- geopandas *
- isoweek *
- matplotlib *
- numpy *
- pandas *
- requests *
- scipy *
- shapely *
- utm *
