tracktable.applications.trajectory_splitter module¶
Module contents¶
tracktable.applications.trajectory_splitter - Split trajectories that are idle for a given amount of time in a given location radius. This is typically to prevent analyzing trajectories of boats that are docked for long periods of time.
split_when_idle() is the main driver function for splitting trajectories.
- tracktable.applications.trajectory_splitter.elapsed_seconds(point1, point2)[source]¶
Calculate the time (in seconds) between two trajectory points. Assumes that point1 is the earlier point.
- Parameters
point1 (Tracktable point) – The eariler occurring trajectory point.
point2 (Tracktable point) – The later occurring trajectory point.
- Returns
The time that has elapsed from the first point to the second point, in seconds.
- tracktable.applications.trajectory_splitter.split_when_idle(trajectory, idle_time_threshold=3600, collocation_radius_threshold=0.2525, min_points=10)[source]¶
If over any subset of points the trajectory stays within an area of
\[PI * collocation_radius_threshold^2,\]for at least idle_time_threshold seconds, call this an idle area. Attempt to create new trajectories before and after the idle area, effectively deleting the idle area.
- Parameters
trajectory (Tracktable trajectory) – The trajectory to split.
- Keyword Arguments
idle_time_threshold (int) – Consider a trajectory area idle if it spends at least idle_time_threshold seconds in the same place. (Default: 3600 (one hour))
collocation_radius_threshold (float) – Consider a trajectory area idle if it stays within an area of PI * collocation_radius_threshold^2 in terms of km. (Default: 0.2525 (creating an area threshold of approx. 0.2 km^2))
min_points (int) – The minimum number of points for a non-idle subinterval of the trajectory to become a new trajectory. (Default: 10)
- Returns
A list of trajectories that are each subintervals of the input trajectory, and do not contain any idle regions (as defined by the input thresholds).