You can use this function to delete trajectory points that meet the specified threshold conditions from a trajectory object.
trajectory ST_removeDriftPoints(trajectory traj, float8 speed, float8 dist, interval offset);
|traj||The trajectory object.|
|speed||The speed threshold. The unit is meter per second.|
|dist||The distance threshold. The unit is meter.|
|offset||The time interval threshold.|
This function deletes the trajectory points that meet the specified conditions from a trajectory object and returns the new data of the trajectory object. The returned trajectory object contains at least two trajectory points. This function deletes a trajectory point if the trajectory point meets the following three conditions: The speed of the trajectory point is greater than the specified speed threshold, the distance from the trajectory point to the previous trajectory point is greater than the specified distance threshold, and the time interval is greater than the specified offset threshold. The unit of speed is meter per second and the unit of distance is meter. If the specified trajectory object has only two trajectory points, no trajectory point is deleted.
The speed parameter specifies a speed threshold. The speed threshold is calculated in real time based on the position of the trajectory point and the time offset. The unit of speed is meter per second. The dist parameter specifies a distance threshold. The unit of distance is meter. The offset parameter specifies a time interval. By default, the coordinate reference system of a trajectory object is World Geodetic System 1984 (WGS 84). If you do not want to use WGS 84, you can specify a spatial reference system identifier (SRID) when you create a trajectory object or invoke the ST_SetSRID function to set an SRID for the trajectory object. The system calculates the spherical distance between two points based on the specified SRID. The unit of spherical distances is meter.
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)