GTFS command-line tool and Python GTFS utility library
Project description
gtfsutils
GTFS command-line tool and Python GTFS utility library
Installation
To install the package from PyPi:
pip install gtfsutils
To install the development version from GitHub:
git clone git@github.com:triply-at/gtfsutils.git
cd gtfsutils
pip install -e . # Install in editable mode
Usage
Python package
The usage of the Python package is illustrated in quickstart.ipynb.
Command-line tool
The package can be also used as a command-line tool. There are three sub-tools available.
Filter
The filter tool applies a spatial filter to a GTFS file. You can either filter based on stop locations or on trip shapes. The filter can be specified either as a bounding box (xmin, ymin, xmax, ymax) or as a file path (e.g. to a GeoJSON or GPKG file).
Here is how to spatially filter a GTFS file based on stop locations, using a bounding box:
gtfsutils filter -t stops data/vienna.gtfs.zip data/vienna-filtered.gtfs.zip "[16.197, 47.999, 16.549, 48.301]"
Here is how to spatially filter a GTFS file based on trip shapes, using a GeoJSON file:
gtfsutils filter -t shapes data/vienna.gtfs.zip data/vienna-filtered.gtfs.zip data/area.geojson
For more information, type:
gtfsutils filter --help
usage: gtfsutils filter [-h] [-t TARGET] [-o OPERATION] [--overwrite] [-v] src dst bounds
positional arguments:
src Input GTFS filepath
dst Output GTFS filepath
bounds Filter boundary
optional arguments:
-h, --help show this help message and exit
-t TARGET, --target TARGET
Filter target (stops, shapes)
-o OPERATION, --operation OPERATION
Filter operation (within, intersects)
--overwrite Overwrite if exists
-v, --verbose Verbose output
Bounds
The bounds tool computes the bounding box (based on stop locations) of a GTFS file:
gtfsutils bounds data/vienna.gtfs.zip
[16.1977025532707, 47.9995020902886, 16.5494019702052, 48.3011051975429]
For more information, type:
gtfsutils bounds --help
usage: gtfsutils bounds [-h] src
positional arguments:
src Input GTFS filepath
optional arguments:
-h, --help show this help message and exit
Info
The info tool print general information about a GTFS file:
gtfsutils info data/vienna.gtfs.zip
GTFS files:
agency.txt 2 rows
calendar.txt 186 rows
calendar_dates.txt 9,575 rows
routes.txt 441 rows
shapes.txt 401,371 rows
stop_times.txt 3,733,781 rows
stops.txt 4,510 rows
trips.txt 201,042 rows
Calender date range:
11.12.2022 - 09.12.2023
Bounding box:
[16.1977025532707, 47.9995020902886, 16.5494019702052, 48.3011051975429]
For more information, type:
gtfsutils info --help
usage: gtfsutils info [-h] src
positional arguments:
src Input GTFS filepath
optional arguments:
-h, --help show this help message and exit
Testing
Prepare dev environment with:
# Create virtual environement
python -m venv ./venv
# Install dependencies
pip install -r requirements-dev.txt
pip install -r requirements.txt
# Activate virtual environment
source venv/bin/activate
To run unit tests, type:
pytest -v
License
This project is licensed under the MIT license. See the LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file gtfsutils-0.0.5.tar.gz
.
File metadata
- Download URL: gtfsutils-0.0.5.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96d4abd5f653087108dedce38cda62818abd3956e2d5129e144c470f1e82e8d4 |
|
MD5 | c062bc49c110f0e56a7a32457bc6cdea |
|
BLAKE2b-256 | d09b2d68015cec8c2341510e4094474acc14002d801382b3652ee0fe533d9566 |
File details
Details for the file gtfsutils-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: gtfsutils-0.0.5-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5143ef53c9daf74080c5ab25f79e755e4c64407a1e0d01e9b0de92fd180a5116 |
|
MD5 | db30b96e0620e694ab29e572efcb56f3 |
|
BLAKE2b-256 | d8c30a2ff433e13e7a5e8294029dd1055919fde837d628f48572b39bf5939c73 |