All Products
Search
Document Center

PolarDB:ST_intersection

Last Updated:Mar 28, 2026

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

ParameterDescription
trajThe trajectory object.
t1The start time of the time range.
t2The end time of the time range.
rangeThe time range, specified as a tsrange value.
gThe 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;