All Products
Search
Document Center

ApsaraDB RDS:ST_intersection

Last Updated:Mar 28, 2026

Returns a geometry representing the spatial intersection of two trajectory objects within a specified time range.

Syntax

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

Use the tsrange overload to pass a prebuilt PostgreSQL timestamp range. Use the timestamp overload to specify start and end times directly.

Parameters

ParameterTypeDescription
traj1trajectoryThe first trajectory object.
traj2trajectoryThe second trajectory object.
rangetsrangeThe time range to evaluate.
t1timestampThe start of the time range.
t2timestampThe end of the time range.

Example

Find 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'
);