All Products
Search
Document Center

PolarDB:ST_removeDriftPoints

Last Updated:Mar 28, 2026

Removes drift points from a trajectory object based on speed, distance, and time interval thresholds.

Syntax

trajectory ST_removeDriftPoints(trajectory traj, float8 speed, float8 dist, interval offset);

Parameters

ParameterTypeDescription
trajtrajectoryThe trajectory object.
speedfloat8Speed threshold, in meters per second.
distfloat8Distance threshold, in meters.
offsetintervalTime interval threshold.

Description

ST_removeDriftPoints removes trajectory points that meet all three of the following conditions and returns the updated trajectory object:

  • The speed at the trajectory point exceeds the speed threshold. Speed is calculated in real time based on position and time offset.

  • The distance from the trajectory point to the previous trajectory point exceeds the dist threshold.

  • The time interval exceeds the offset threshold.

The returned trajectory object always contains at least two trajectory points. If the input trajectory has exactly two points, no points are removed.

Note

By default, the coordinate reference system is World Geodetic System 1984 (WGS 84). To use a different coordinate reference system, specify a spatial reference system identifier (SRID) when creating the trajectory object, or call ST_SetSRID to set the SRID afterward. Spherical distances between points are calculated based on the specified SRID, in meters.

Examples

SELECT id, st_leafcount(traj) FROM table_name WHERE id = 1;
 id | st_leafcount
----+--------------
  1 |           53
(1 row)

UPDATE table_name SET traj=st_removeDriftPoints(traj, 25.72, 9620, interval '30 seconds') WHERE id = 1;

--Two trajectory points are deleted.
SELECT id, st_leafcount(traj) FROM table_name WHERE id = 1;
 id | st_leafcount
----+--------------
  1 |           49
(1 row)

See also

  • ST_leafcount: Returns the number of trajectory points in a trajectory object. Use this function to verify the result of ST_removeDriftPoints.

  • ST_SetSRID: Sets the SRID for a trajectory object when you need to use a coordinate reference system other than WGS 84.