Preprocessing

The preprocessing module contains a variety of functions to transform mobility and tracking data into richer data sources.

Staypoints

trackintel.preprocessing.positionfixes.extract_staypoints(positionfixes, method='sliding', dist_threshold=100, time_threshold=300, epsilon=100, dist_func=<function haversine_dist>)

Extract staypoints from positionfixes.

Parameters:
positionfixes : GeoDataFrame

The positionfixes have to follow the standard definition for positionfixes DataFrames.

method : {‘sliding’ or ‘dbscan’}

The following methods are available to extract staypoints from positionfixes:

‘sliding’ : Applies a sliding window over the data. ‘dbscan’ : Uses the DBSCAN algorithm to find clusters of staypoints.

dist_threshold : float

The distance threshold for the ‘sliding’ method, i.e., how far someone has to travel to generate a new staypoint.

time_threshold : float

The time threshold for the ‘sliding’ method in seconds, i.e., how long someone has to stay within an area to consider it as a staypoint.

epsilon : float

The epsilon for the ‘dbscan’ method.

dist_func : function

A function that expects (lon_1, lat_1, lon_2, lat_2) and computes a distance in meters.

Returns:
GeoDataFrame

A new GeoDataFrame containing points where a person spent some time.

References

Zheng, Y. (2015). Trajectory data mining: an overview. ACM Transactions on Intelligent Systems and Technology (TIST), 6(3), 29.

Li, Q., Zheng, Y., Xie, X., Chen, Y., Liu, W., & Ma, W. Y. (2008, November). Mining user similarity based on location history. In Proceedings of the 16th ACM SIGSPATIAL international conference on Advances in geographic information systems (p. 34). ACM.

Examples

>>> extract_staypoints(...)