• Stars
    star
    204
  • Rank 192,063 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 6 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

trackintel is a framework for spatio-temporal analysis of movement trajectory and mobility data.

The trackintel framework

PyPI version Conda Version Actions Status Documentation Status codecov.io Code style: black asv

trackintel is a library for the analysis of spatio-temporal tracking data with a focus on human mobility. The core of trackintel is the hierarchical data model for movement data that is used in GIS, transport planning and related fields. We provide functionalities for the full life-cycle of human mobility data analysis: import and export of tracking data of different types (e.g, trackpoints, check-ins, trajectories), preprocessing, data quality assessment, semantic enrichment, quantitative analysis and mining tasks, and visualization of data and results. Trackintel is based on Pandas and GeoPandas.

You can find the documentation on the trackintel documentation page.

Try trackintel online in a MyBinder notebook: Binder

Please star this repo and cite our paper if you find our work is helpful for you.

Data model

An overview of the data model of trackintel:

  • positionfixes (Raw tracking points, e.g., GPS recordings or check-ins)
  • staypoints (Locations where a user spent time without moving, e.g., aggregations of positionfixes or check-ins). Staypoints can be classified into the following categories:
    • activity staypoints. Staypoints with a purpose and a semantic label, e.g., stopping at a cafe to meet with friends or staying at the workplace.
    • non-activity staypoints. Staypoints without an explicit purpose, e.g., waiting for a bus or stopping in a traffic jam.
  • locations (Important places that are visited more than once, e.g., home or work location)
  • triplegs (or stages) (Continuous movement without changing mode, vehicle or stopping for too long, e.g., a taxi trip between pick-up and drop-off)
  • trips (The sequence of all triplegs between two consecutive activity staypoints)
  • tours (A collection of sequential trips that return to the same location)

An example plot showing the hierarchy of the trackintel data model can be found below:

The image below explicitly shows the definition of locations as clustered staypoints, generated by one or several users.

You can enter the trackintel framework if your data corresponds to any of the above mentioned movement data representation. Here are some of the functionalities that we provide:

  • Import: Import from the following data formats is supported: geopandas dataframes (recommended), csv files in a specified format, postGIS databases. We also provide specific dataset readers for popular public datasets (e.g, geolife).
  • Aggregation: We provide functionalities to aggregate into the next level of our data model. E.g., positionfixes->staypoints; positionfixes->triplegs; staypoints->locations; staypoints+triplegs->trips; trips->tours
  • Enrichment: Activity semantics for staypoints; Mode of transport semantics for triplegs; High level semantics for locations

How it works

trackintel provides support for the full life-cycle of human mobility data analysis.

[1.] Import data.

import geopandas as gpd
import trackintel as ti

# read pfs from csv file
pfs = ti.io.file.read_positionfixes_csv(".\examples\data\pfs.csv", sep=";", index_col="id")
# or with predefined dataset readers (here geolife) 
pfs, _ = ti.io.dataset_reader.read_geolife(".\tests\data\geolife_long")

[2.] Data model generation.

# generate staypoints and triplegs
pfs, sp = pfs.as_positionfixes.generate_staypoints(method='sliding')
pfs, tpls = pfs.as_positionfixes.generate_triplegs(sp, method='between_staypoints')

[3.] Visualization.

# plot the generated tripleg result
ti.plot(positionfixes=pfs, staypoints=sp, triplegs=tpls, radius_sp=10)

[4.] Analysis.

# e.g., predict travel mode labels based on travel speed
tpls = tpls.as_triplegs.predict_transport_mode()
# or calculate the temporal tracking coverage of users
tracking_coverage = ti.temporal_tracking_quality(tpls, granularity='all')

[5.] Save results.

# save the generated results as csv file 
sp.as_staypoints.to_csv('.\examples\data\sp.csv')
tpls.as_triplegs.to_csv('.\examples\data\tpls.csv')

For example, the plot below shows the generated staypoints and triplegs from the imported raw positionfix data.

Installation and Usage

trackintel is on pypi.org and conda-forge. We recommend installing trackintel via conda-forge:

conda install -c conda-forge trackintel

Alternatively, you can install it with pip in a GeoPandas available environment using:

pip install trackintel

You should then be able to run the examples in the examples folder or import trackintel using:

import trackintel as ti

ti.print_version() 

Requirements and dependencies

  • Numpy
  • GeoPandas
  • Matplotlib
  • Pint
  • NetworkX
  • GeoAlchemy2
  • scikit-learn
  • tqdm
  • OSMnx
  • similaritymeasures

Development

You can find the development roadmap under ROADMAP.md and further development guidelines under CONTRIBUTING.md.

Contributors

trackintel is primarily maintained by the Mobility Information Engineering Lab at ETH Zurich (mie-lab.ethz.ch). If you want to contribute, send a pull request and put yourself in the AUTHORS.md file.

Citation

If you find this code useful for your work or use it in your project, please consider citing:

@article{Martin_2023_trackintel,
  doi = {10.1016/j.compenvurbsys.2023.101938},
  volume = {101},
  pages = {101938},
  author = {Henry Martin and Ye Hong and Nina Wiedemann and Dominik Bucher and Martin Raubal},
  keywords = {Human mobility analysis, Open-source software, Transport planning, Data mining, Python, Tracking studies},
  title = {Trackintel: An open-source Python library for human mobility analysis},
  journal = {Computers, Environment and Urban Systems},
  year = {2023},
}

More Repositories

1

location-prediction

[TRC] Context-aware next location prediction
Python
29
star
2

location-mode-prediction

[SIGSPATIAL '22] Next location prediction considering travel mode
Python
14
star
3

spatial_rf_python

Benchmarking of spatial regression methods with respect to spatial heterogeneity, and providing a Python implementation of spatial Random Forests
Jupyter Notebook
9
star
4

Graph-based-mobility-profiling

Code accompanying our paper "Graph-based Mobility Profiling"
Python
7
star
5

traffic4cast

Submission to the iarai traffic4cast competition
Python
6
star
6

traffic4cast-Graph-ResNet

Python
5
star
7

V2G-carsharing-RL-environment

V2G for car sharing thesis project
Jupyter Notebook
4
star
8

mode_detect

[JTRG] Geospatial context importance for travel mode detection
Jupyter Notebook
4
star
9

trip_purpose_privacy

Understanding the predictability of activity purposes
Python
3
star
10

bike_lane_optimization

Python
3
star
11

change-detection

[GIScience '21] Travel behaviour change detection study
Python
3
star
12

reprotrack

SCSS
1
star
13

rooftop-PV-EV-charging

Python
1
star
14

trackintel-docs

The trackintel documentation, please visit:
HTML
1
star
15

Complexity-Aware-Traffic-Prediction

HTML
1
star
16

topology_privacy

How privacy-preserving are graph representations of mobiltiy
Python
1
star
17

train_delay

Python
1
star
18

graph-trackintel

Tools for building and preprocessing location graphs
Python
1
star
19

v2g4carsharing

Vehicle-to-grid strategies for car sharing systems
Python
1
star
20

ev_homepv

A project to analyze how much of our mobility energy demand (induced by electric vehicles) we can cover by using only pv installed on our own home.
Python
1
star
21

geospatial_optimal_transport

Python
1
star