gtfs2nx
Create routable NetworkX graph with realistic transfer times from GTFS feeds. 🚌 🚆 🚡
How
- Cleaning & preprocessing
- Remove trips with unrealistic travel times and speeds
- Fix trips contradictory stop sequences and departure times
- Enable routability
- Ensure each node belongs only to single route
- Calculate average segment travel times
- Calculate average stop headway and service frequency
- Add edges for walking transfer between routes with realistic transfer time (walking time + headway / 2)
Install
pip install gtfs2nx
Usage
import gtfs2nx as gx
G = gx.transit_graph('path/to/GTFS-feed.zip')
Customize transit network:
G = gx.transit_graph(
gtfs_paths='path/to/GTFS-feed.zip',
time_window=('06:00', '08:00'),
route_types=[700], # only buses
walk_transfer_max_distance=400, # allow transfers with long walking distance
)
See the API docs for more details and the getting-started notebook for a small demo.
Exemplary NetworkX analysis
import networkx as nx
# access precomputed stop characteristics
frequency = nx.get_node_attributes(G, 'frequency')
# routing
route = nx.shortest_path(G, from_stop, to_stop, weight='weight')
# travel time to other stops
travel_times = nx.single_source_dijkstra_path_length(G, source=from_stop, weight='weight')
# centrality analysis
centrality = nx.closeness_centrality(G, distance='weight')
Further use cases
- Using graph neural networks to classify missing GTFS route types
- Validating NetworkX transit graph: Comparing routes and travel times to Google Maps
Development
Build from source using poetry:
poetry build
pip install dist/gtfs2nx-*.whl
Configure post-checkout hook for branch specific .gitignore files:
git config --local core.hooksPath .githooks/
Metadata
Release files for gtfs2nx 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gtfs2nx-0.2.1.tar.gz | 10.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gtfs2nx-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.5 kB
Release files / gtfs2nx-0.2.1.tar.gz
| Download URL | gtfs2nx-0.2.1.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e159fe6454170afd5474affbfde6a851f04f6cb3eb86641932dbb7820d98a058
|
|
BLAKE2b-256 checksum How to use checksums |
9e78304810a6a68c4ef635f1dbbb108651098758e4160f97541936941701135d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.4 Darwin/22.1.0
|
Release files / gtfs2nx-0.2.1-py3-none-any.whl
| Download URL | gtfs2nx-0.2.1-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1fb002d7e4577ada8c66ae29c9ddfe984a9dfa6653f6320d059f5e80db8745b1
|
|
BLAKE2b-256 checksum How to use checksums |
746812f98d2bdf51409255705b1b4e5836c33150a9c00c26be7b5940c4f0a56b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.4 Darwin/22.1.0
|