Returns the portions of a trajectory that fall within a specified time range and intersect a specified geometry. If the trajectory crosses the geometry at multiple locations, the function returns one sub-trajectory per crossing.
Syntax
trajectory[] ST_intersection(trajectory traj, tsrange range, geometry g);
trajectory[] ST_intersection(trajectory traj, timestamp t1, timestamp t2, geometry g);Parameters
| Parameter | Description |
|---|---|
traj | The trajectory object. |
t1 | The start time of the time range. |
t2 | The end time of the time range. |
range | The time range, specified as a tsrange value. |
g | The geometry object to intersect with. |
Examples
Basic usage: extract the segment of a trajectory that crosses a line
SELECT ST_intersection(
traj,
'2010-1-1 13:00:00',
'2010-1-1 14:00:00',
'LINESTRING(0 0, 5 5, 9 9)'::geometry
)
FROM traj_table;