A toolkit for inferencing trips and trip metadata from Itinerum GPS data
Project description
itinerum-tripkit
Documentation for library usage: https://itinerum-tripkit.readthedocs.io/
This library serves as a framework to process data from the Itinerum platform and hardware GPS loggers (e.g., QStarz). It can be used both through as a library in Jupyter to explore datasets interactively or imported as a module in standalone scripts and applications.
This repository also serves as the development bed for the Itinerum platform algorithms within the TRIP Lab repositories.
Looking to get started without coding? Try the itinerum-tripkit-cli!
Setup
Quickstart
- Install this library from PyPI (a Python virtual environment is recommended)
- Create a configuration file with input filepaths, output filepaths, and trip processing parameters. See the included
tripkit_config.py
file for a full example. - Import
tripkit
as a dependency in a notebook or script
For more complete installation information, see the official itinerum-tripkit documentation.
Loading Subway Stations
Subway station data for trip detection can be loaded similarly for all processing modules. Place a .csv file of station entrances with the columns of x
(or longitude
) and y
(or latitude
). Locations are expected as geographic coordinates only. Edit the SUBWAY_STATIONS_FP
config parameter to reflect the subway stations .csv filepath.
Example
View attributes on a User
import tripkit_config
itinerum = Itinerum(tripkit_config)
# create a new database and read in .csv data
itinerum.setup()
# load all users from database
users = itinerum.load_all_users()
test_user = users[0]
print(test_user.coordinates)
print(test_user.prompt_responses)
Run trip detection on a User
import tripkit_config
itinerum = Itinerum(tripkit_config)
# load user from database by uuid
user = itinerum.database.load_user('00000000-0000-0000-0000-000000000000')
# run a provided trip detection algorithm
parameters = {
'subway_entrances': itinerum.database.load_subway_entrances(),
'break_interval_seconds': tripkit_config.TRIP_DETECTION_BREAK_INTERVAL_SECONDS,
'subway_buffer_meters': tripkit_config.TRIP_DETECTION_SUBWAY_BUFFER_METERS,
'cold_start_distance': tripkit_config.TRIP_DETECTION_COLD_START_DISTANCE_METERS,
'accuracy_cutoff_meters': tripkit_config.TRIP_DETECTION_ACCURACY_CUTOFF_METERS
}
trips = itinerum.process.trip_detection.triplab.v2.algorithm.run(user.coordinates, parameters)
Processing
Trip Detection
Arguments | |
---|---|
parameters |
A dictionary to supply arbitrary kwargs to an algorithm |
subway_stations |
A list of subway station entrance database objects containing latitude and longitude attributes |
coordinates |
A timestamp-ordered list of coordinates as dicts for a specific user. Multiple users should be run in sequence and have their output coordinates concatenated into a single list after if desired. |
Trip Outputs
Trips will be output with the following trip codes to indicate the type of trip:
Trip Code | Description |
---|---|
1 | Complete trip |
2 | Complete trip - subway |
101 | Missing trip |
102 | Missing trip - subway |
103 | Missing trip - less than 250m |
201 | Single point |
202 | Distance too short - less than 250m |
Outputs
The aim of this library is to provide easy visualization of Itinerum data to assist in writing trip processing algorthms. Therefore at a minimum, the library provides exporting processed coordinates and traces as .geojson files (TBA: GeoPackage format). With a PostgreSQL backend for caching, PostGIS can be enabled (unimplemented) and a geom
column generated for directly connection QGIS to the output data. The library should also easily provide methods for easily plotting GPS within Jupyter notebooks.
Project details
Release history Release notifications | RSS feed
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 itinerum-tripkit-0.0.26.tar.gz
.
File metadata
- Download URL: itinerum-tripkit-0.0.26.tar.gz
- Upload date:
- Size: 88.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffcc39d67ad505365216453f6686021da872c789bc52333124349eebb141cb3f |
|
MD5 | 73c88dff3a175e1a5f3117c8ebd880b7 |
|
BLAKE2b-256 | ff356bdaf4478a217141c9e786b54f40e3601a79541cde7a16f8129a0cb1ff7a |
File details
Details for the file itinerum_tripkit-0.0.26-py3-none-any.whl
.
File metadata
- Download URL: itinerum_tripkit-0.0.26-py3-none-any.whl
- Upload date:
- Size: 127.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33e6e4a5d574fd4a6cf02c356f960a8ca1a110869c4dc62e987deb5b9e873345 |
|
MD5 | a27cbf094c0377db3fdc958a6f20ba0b |
|
BLAKE2b-256 | de578c8933b7e4dfd5bf14fcaf51a0d0056787987a91512ccfc6b6adba27945e |