All Products
Search
Document Center

PolarDB:ST_intersection

Last Updated:Mar 28, 2026

Computes the spatial intersection of two trajectory objects within a specified time range and returns the result as a geometry value.

Syntax

geometry ST_intersection(trajectory traj1, trajectory traj2, tsrange range);
geometry ST_intersection(trajectory traj1, trajectory traj2, timestamp t1, timestamp t2);

Parameters

ParameterTypeDescription
traj1trajectoryThe first trajectory object.
traj2trajectoryThe second trajectory object.
t1timestampThe start time of the time range.
t2timestampThe end time of the time range.
rangetsrangeThe time range, expressed as a tsrange value.

Return value

Returns a geometry value representing the spatial intersection of traj1 and traj2 within the specified time range.

Examples

The following example retrieves the spatial intersection of two trajectories between 13:00 and 14:00 on January 1, 2010.

SELECT ST_intersection(
  (SELECT traj FROM traj_table WHERE id = 1),
  (SELECT traj FROM traj_table WHERE id = 2),
  '2010-1-1 13:00:00',
  '2010-1-1 14:00:00'
);