Returns a trajectory object representing the part of a trajectory, within a specified time range, that does not intersect with a geometry object.
Syntax
trajectory ST_difference(trajectory traj, tsrange range, geometry g);
trajectory ST_difference(trajectory traj, timestamp t1, timestamp t2, geometry g);Parameters
| Parameter | Type | Description |
|---|---|---|
traj | trajectory | The trajectory object. |
range | tsrange | The time range within which to compute the difference. |
t1 | timestamp | The start time of the time range. |
t2 | timestamp | The end time of the time range. |
g | geometry | The specified geometry object. |
Example
The following example uses the timestamp variant to return the segments of a trajectory between 13:00 and 14:00 that fall outside the specified line string.
SELECT ST_difference(traj, '2010-1-1 13:00:00', '2010-1-1 14:00:00', 'LINESTRING(0 0, 5 5, 9 9)'::geometry)
FROM traj_table;
-- Returns the trajectory segments within the time window that do not intersect LINESTRING(0 0, 5 5, 9 9)