Skip to main content

Human mobility and movement analysis framework.

Project description

The trackintel framework

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

trackintel is a library for the analysis of spatio-temporal tracking data with a focus on human mobility. The core of trackintel is the hierachical data model for movement data that is used in GIS, transport planning and related fields [1]. 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
tpls.as_triplegs.plot(positionfixes=pfs, staypoints=sp, staypoints_radius=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, you can install it 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
  • pygeos

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:

@misc{Martin_2022_arxiv,
  doi = {10.48550/ARXIV.2206.03593},
  url = {https://arxiv.org/abs/2206.03593},
  author = {Martin, Henry and Hong, Ye and Wiedemann, Nina and Bucher, Dominik and Raubal, Martin},
  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},
  publisher = {arXiv},
  year = {2022},
  copyright = {Creative Commons Attribution 4.0 International}
}

References

[1] Axhausen, K. W. (2007). Definition Of Movement and Activity For Transport Modelling. In Handbook of Transport Modelling. Emerald Group Publishing Limited.

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

trackintel-1.1.10.tar.gz (111.5 kB view details)

Uploaded Source

Built Distribution

trackintel-1.1.10-py3-none-any.whl (144.5 kB view details)

Uploaded Python 3

File details

Details for the file trackintel-1.1.10.tar.gz.

File metadata

  • Download URL: trackintel-1.1.10.tar.gz
  • Upload date:
  • Size: 111.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for trackintel-1.1.10.tar.gz
Algorithm Hash digest
SHA256 6931a79f73b717c5d95a081ecb8db96810838e942af0699cc15a7ceceec0e9fb
MD5 be0c468b37aa306ff72b93e924ae0b6e
BLAKE2b-256 7d9f8cb5ecbfcb563e2d69f93fc4169f44e9a5f21da43cbc9f2a574cff441992

See more details on using hashes here.

File details

Details for the file trackintel-1.1.10-py3-none-any.whl.

File metadata

  • Download URL: trackintel-1.1.10-py3-none-any.whl
  • Upload date:
  • Size: 144.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for trackintel-1.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 8e515fecdf8ba67c50b4a112b5965d93fc754f4021a13ac9e095c961c5c754a6
MD5 601c11202a8bf132ae1875075adfa02d
BLAKE2b-256 a37b8e280f6a312316553ce158dd06f8c950b19c0e9c5f698bccd1beb9b2cab5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page