MovingPandas.TrajectoryStopDetector#

movingpandas: Implementation of Trajectory classes and functions built on top of GeoPandas

class movingpandas.TrajectoryStopDetector(traj, n_processes=1, **kwargs)#

Detects stops in a trajectory. A stop is detected if the movement stays within an area of specified size for at least the specified duration.

__init__(traj, n_processes=1, **kwargs)#

Create a StopDetector.

Parameters:
  • traj (Trajectory or TrajectoryCollection) – The trajectory or collection of trajectories to analyze.

  • n_processes (int or None, optional) – Number of processes to use for computation (default: 1). If set to None, the number of processes will be set to os.cpu_count() (or os.process_cpu_count() in Python 3.13+), enabling full CPU utilization via multiprocessing.

  • n_threads (int, optional) – DEPRECATED. Use n_processes instead. This parameter will be removed in a future version.

Raises:

ValueError – If both n_processes and the deprecated n_threads are provided.

get_stop_points(max_diameter, min_duration)#

Returns detected stop location points.

Parameters:
  • max_diameter (float) – Maximum diameter for stop detection. (Distances will be calculated in meters using geodesic distance calculations for geographic projections (e.g. EPSG:4326 WGS84) and in CRS units for all other projections)

  • min_duration (datetime.timedelta) – Minimum stop duration

Returns:

Stop locations as points with start and end time and stop duration in seconds

Return type:

geopandas.GeoDataFrame

Examples

>>> detector = mpd.TrajectoryStopDetector(traj)
>>> stops = detector.get_stop_points(min_duration=timedelta(seconds=60),
                                     max_diameter=100)
get_stop_segments(max_diameter, min_duration)#

Returns detected stop trajectory segments.

Parameters:
  • max_diameter (float) – Maximum diameter for stop detection. (Distances will be calculated in meters using geodesic distance calculations for geographic projections (e.g. EPSG:4326 WGS84) and in CRS units for all other projections)

  • min_duration (datetime.timedelta) – Minimum stop duration

Returns:

Trajectory segments

Return type:

TrajectoryCollection

Examples

>>> detector = mpd.TrajectoryStopDetector(traj)
>>> stops = detector.get_stop_segments(min_duration=timedelta(seconds=60),
                                       max_diameter=100)
get_stop_time_ranges(max_diameter, min_duration)#

Returns detected stop start and end times.

Parameters:
  • max_diameter (float) – Maximum diameter for stop detection. (Distances will be calculated in meters using geodesic distance calculations for geographic projections (e.g. EPSG:4326 WGS84) and in CRS units for all other projections)

  • min_duration (datetime.timedelta) – Minimum stop duration

Returns:

TemporalRanges of detected stops

Return type:

list