Trackintel - an open-source python library for human mobility data analysis

program image

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

Data model

An overview of the data model of trackintel:

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:

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.read_positionfixes_csv(".\examples\data\pfs.csv", sep=";", index_col="id")
# or with predefined dataset readers (here geolife) 
pfs, _ = ti.io.read_geolife(".\tests\data\geolife_long")

[2.] Data model generation.

# generate staypoints and triplegs
pfs, sp = pfs.generate_staypoints(method='sliding')
pfs, tpls = pfs.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.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.to_csv(r'.\examples\data\sp.csv')
tpls.to_csv(r'.\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() 

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.