All Products
Search
Document Center

PolarDB:ST_difference

Last Updated:Mar 28, 2026

Returns a new trajectory object containing the points of a trajectory, within a specified time range, that fall outside a given geometry object.

Syntax

trajectory ST_difference(trajectory traj, tsrange range, geometry g);
trajectory ST_difference(trajectory traj, timestamp t1, timestamp t2, geometry g);

Parameters

ParameterDescription
trajThe trajectory object.
rangeThe time range, specified as a tsrange value.
t1The start time of the time range.
t2The end time of the time range.
gThe geometry object to compare against.

Example

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;