All Products
Search
Document Center

AnalyticDB:ST_trajectoryTemporal

Last Updated:Mar 28, 2026

Returns the timeline of a trajectory object as a JSON text string.

Syntax

text ST_trajectoryTemporal(trajectory traj);
text ST_trajTemporal(trajectory traj);

ST_trajTemporal is an alias for ST_trajectoryTemporal.

Parameters

ParameterTypeDescription
trajtrajectoryThe trajectory object.

Return value

Returns a text value containing a JSON object with a timeline key. The timeline value is an array of timestamps that represent each point in the trajectory, in chronological order.

Example output:

{"timeline":["2010-01-01 14:30:00","2010-01-01 15:00:00","2010-01-01 15:30:00"]}

Examples

The following example retrieves the timeline from a trajectory built from a three-point LINESTRING spanning one hour.

SELECT ST_trajectoryTemporal(
  ST_MakeTrajectory(
    'STPOINT'::leaftype,
    ST_GeomFromText('LINESTRING (114 35, 115 36, 116 37)', 4326),
    '[2010-01-01 14:30, 2010-01-01 15:30)'::tsrange,
    null
  )
);

Output:

                          st_trajectorytemporal
--------------------------------------------------------------------------------
 {"timeline":["2010-01-01 14:30:00","2010-01-01 15:00:00","2010-01-01 15:30:00"]}
(1 row)