Return the trajectory or the traversed area
trajectory(tpoint,unary_union boolean=false) → geo traversedArea(tgeo,unary_union boolean=false) → geo
This function is equivalent to getValues for temporal alphanumeric values. The last argument states whether the PostGIS function ST_UnaryUnion is applied to remove redundant geometries in the result. Notice that setting this argument to true is computationally expensive.
SELECT ST_AsText(trajectory(tgeompoint '[Point(0 0)@2001-01-01, Point(0 1)@2001-01-02,
Point(0 0)@2001-01-03]'));
-- LINESTRING(0 0,0 1,0 0)
SELECT ST_AsText(trajectory(tgeompoint '[Point(0 0)@2001-01-01, Point(0 1)@2001-01-02,
Point(0 0)@2001-01-03]', true));
-- LINESTRING(0 0,0 1)
SELECT ST_AsText(trajectory(tgeompoint '{[Point(0 0)@2001-01-01, Point(0 1)@2001-01-02),
[Point(0 1)@2001-01-03, Point(0 0)@2001-01-04)}'));
-- LINESTRING(0 0,0 1)
SELECT ST_AsText(trajectory(tgeompoint 'Interp=Step;{[Point(0 0)@2001-01-01,
Point(0 1)@2001-01-02], [Point(0 1)@2001-01-03, Point(1 1)@2001-01-04]}'));
-- MULTIPOINT((0 0),(1 1),(0 1))
SELECT ST_AsText(traversedArea(tgeometry '[Point(1 1)@2001-01-01, Linestring(1 1,2 2)@2001-01-02, Point(1 1)@2001-01-03]')); -- GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(1 1,2 2)) SELECT ST_AsText(traversedArea(tgeometry '[Point(1 1)@2001-01-01, Linestring(1 1,2 2)@2001-01-02, Point(1 1)@2001-01-03]', true)); -- LINESTRING(1 1,2 2)
Return the space-time volume, the integral of the area over the time
spaceTimeVolume(tgeometry) → float spaceTimeVolume(tgeography,spheroid boolean=true) → float
A temporal geometry or geography holds each of its values up to its next instant, so the volume is the sum of the area of each value times the length of its interval. The time is read in microseconds, as integral reads it, so the result is in the square units of the value, square meters for a geography, times microseconds: dividing it by the microseconds of a unit of time, as the examples do for a day, reads it in that unit. For geographies, the area is computed on the WGS 84 spheroid by default, and on the sphere if the last argument is false. A value of instants holds no value over an interval and has a volume of zero; a value with Z coordinates is refused.
SELECT spaceTimeVolume(tgeometry '[Polygon((0 0,2 0,2 2,0 2,0 0))@2001-01-01,
Polygon((1 1,3 1,3 3,1 3,1 1))@2001-01-02]') / (24 * 3600 * 1e6);
-- 4
SELECT spaceTimeVolume(tgeometry '{[Polygon((0 0,2 0,2 2,0 2,0 0))@2001-01-01,
Polygon((0 0,2 0,2 2,0 2,0 0))@2001-01-02], [Polygon((0 0,1 0,1 1,0 1,0 0))@2001-01-03,
Polygon((0 0,1 0,1 1,0 1,0 0))@2001-01-05]}') / (24 * 3600 * 1e6);
-- 6
Return the centroid as a temporal point
centroid(tgeo) → tpoint centroid(tgeography,spheroid boolean=true) → tgeogpoint
For geographies, the computation is done on the WGS 84 spheroid by default. If the last argument is false, a faster spherical calculation is used.
SELECT asText(centroid(tgeometry '[Point(1 1)@2001-01-01, Linestring(1 1,3 3)@2001-01-02,
Polygon((1 1,4 4,7 1,1 1))@2001-01-03]'));
-- Interp=Step;[POINT(1 1)@2001-01-01, POINT(2 2)@2001-01-02, POINT(4 2)@2001-01-03]
SELECT asText(centroid(tgeography '[MultiPoint(1 1,4 4,7 1)@2001-01-01,
Polygon((1 1,4 4,7 1,1 1))@2001-01-02]'),6);
-- Interp=Step;[POINT(4 2.001727)@2001-01-01, POINT(4 2.001727)@2001-01-02]
SELECT asText(centroid(tgeography '{Linestring(0 0,0 1,1 1)@2001-01-01}', false), 6);
-- {POINT(0.249967 0.750007)@2001-01-01}
Return the X/Y/Z coordinate values as a temporal float
getX(tpoint) → tfloat getY(tpoint) → tfloat getZ(tpoint) → tfloat
SELECT getX(tgeompoint '{Point(1 2)@2001-01-01, Point(3 4)@2001-01-02,
Point(5 6)@2001-01-03}');
-- {1@2001-01-01, 3@2001-01-02, 5@2001-01-03}
SELECT getX(tgeogpoint 'Interp=Step;
[Point(1 2 3)@2001-01-01, Point(4 5 6)@2001-01-02, Point(7 8 9)@2001-01-03]');
-- Interp=Step;[1@2001-01-01, 4@2001-01-02, 7@2001-01-03]
SELECT getY(tgeompoint '{Point(1 2)@2001-01-01, Point(3 4)@2001-01-02,
Point(5 6)@2001-01-03}');
-- {2@2001-01-01, 4@2001-01-02, 6@2001-01-03}
SELECT getY(tgeogpoint 'Interp=Step;
[Point(1 2 3)@2001-01-01, Point(4 5 6)@2001-01-02, Point(7 8 9)@2001-01-03]');
-- Interp=Step;[2@2001-01-01, 5@2001-01-02, 8@2001-01-03]
SELECT getZ(tgeompoint '{Point(1 2)@2001-01-01, Point(3 4)@2001-01-02,
Point(5 6)@2001-01-03}');
-- The temporal point must have Z dimension
SELECT getZ(tgeogpoint 'Interp=Step;
[Point(1 2 3)@2001-01-01, Point(4 5 6)@2001-01-02, Point(7 8 9)@2001-01-03]');
-- Interp=Step;[3@2001-01-01, 6@2001-01-02, 9@2001-01-03]
Return true if the temporal point does not spatially self-intersect
isSimple(tpoint) → boolean
Notice that a temporal sequence set point is simple if every composing sequence is simple.
SELECT isSimple(tgeompoint '[Point(0 0)@2001-01-01, Point(1 1)@2001-01-02,
Point(0 0)@2001-01-03]');
-- false
SELECT isSimple(tgeompoint '[Point(0 0 0)@2001-01-01, Point(1 1 1)@2001-01-02,
Point(2 0 2)@2001-01-03, Point(0 0 0)@2001-01-04]');
-- false
SELECT isSimple(tgeompoint '{[Point(0 0 0)@2001-01-01, Point(1 1 1)@2001-01-02],
[Point(1 1 1)@2001-01-03, Point(0 0 0)@2001-01-04]}');
-- true
Return the length traversed by the temporal point
length(tpoint) → float
length(geo) → float
length({geography,tgeogpoint},spheroid boolean=true) → float
The function length returns the length of a geometry or a geography, the one of a geography in meters on the spheroid, as the PostGIS function ST_Length does. If the last argument is false, a faster spherical calculation is used.
SELECT length(tgeompoint '[Point(0 0 0)@2001-01-01, Point(1 1 1)@2001-01-02]'); -- 1.73205080756888 SELECT length(tgeompoint '[Point(0 0 0)@2001-01-01, Point(1 1 1)@2001-01-02, Point(0 0 0)@2001-01-03]'); -- 3.46410161513775 SELECT length(tgeompoint 'Interp=Step; [Point(0 0 0)@2001-01-01, Point(1 1 1)@2001-01-02, Point(0 0 0)@2001-01-03]'); -- 0 SELECT length(geometry 'Linestring(0 0,3 4)'); -- 5 SELECT round(length(geography 'Linestring(4.35 50.85,4.40 50.85)'), 6); -- 3521.188745 SELECT round(length(tgeogpoint '[Point(0 1)@2001-01-01, Point(0 2)@2001-01-02]', false), 3); -- 111195.08
Return the cumulative length traversed by the temporal point
cumulativeLength(tpoint) → tfloatSeq cumulativeLength(tgeogpoint,spheroid boolean=true) → tfloatSeq
For geographies, the computation is done on the WGS 84 spheroid by default. If the last argument is false, a faster spherical calculation is used.
SELECT round(cumulativeLength(tgeompoint '{[Point(0 0)@2001-01-01, Point(1 1)@2001-01-02,
Point(1 0)@2001-01-03], [Point(1 0)@2001-01-04, Point(0 0)@2001-01-05]}'), 6);
-- {[0@2001-01-01, 1.414214@2001-01-02, 2.414214@2001-01-03],
[2.414214@2001-01-04, 3.414214@2001-01-05]}
SELECT cumulativeLength(tgeompoint 'Interp=Step;
[Point(0 0 0)@2001-01-01, Point(1 1 1)@2001-01-02, Point(0 0 0)@2001-01-03]');
-- Interp=Step;[0@2001-01-01, 0@2001-01-03]
SELECT round(cumulativeLength(tgeogpoint '[Point(0 1)@2001-01-01, Point(0 2)@2001-01-02]',
false), 3);
-- [0@2001-01-01, 111195.08@2001-01-02]
Return the speed of the temporal point in units per second
speed(tpoint) → tfloatSeqSet speed(tgeogpoint,spheroid boolean=true) → tfloatSeqSet
The temporal point must have linear interpolation. For geographies, the computation is done on the WGS 84 spheroid by default. If the last argument is false, a faster spherical calculation is used.
SELECT speed(tgeompoint '{[Point(0 0)@2001-01-01, Point(1 1)@2001-01-02,
Point(1 0)@2001-01-03], [Point(1 0)@2001-01-04, Point(0 0)@2001-01-05]}') * 3600 * 24;
/* Interp=Step;{[1.4142135623731@2001-01-01, 1@2001-01-02, 1@2001-01-03],
[1@2001-01-04, 1@2001-01-05]} */
SELECT speed(tgeompoint 'Interp=Step;
[Point(0 0)@2001-01-01, Point(1 1)@2001-01-02, Point(1 0)@2001-01-03]');
-- ERROR: The temporal value must have linear interpolation
SELECT round(speed(tgeogpoint '[Point(0 1)@2001-01-01, Point(0 2)@2001-01-02]',
false), 6);
-- Interp=Step;[1.28698@2001-01-01, 1.28698@2001-01-02]
Return the time-weighted centroid
twCentroid(tgeompoint) → point
SELECT ST_AsText(twCentroid(tgeompoint '{[Point(0 0 0)@2001-01-01,
Point(0 1 1)@2001-01-02, Point(0 1 1)@2001-01-03, Point(0 0 0)@2001-01-04)}'));
-- POINT Z (0 0.666666666666667 0.666666666666667)
Return the direction, that is, the azimuth between the start and end locations
direction(tpoint) → float
The result is expressed in radians. It is NULL if there is only one location or if the start and end locations are equal.
SELECT round(degrees(direction(tgeompoint '[Point(0 0)@2001-01-01,
Point(-1 -1)@2001-01-02, Point(1 1)@2001-01-03]'))::numeric, 6);
-- 45.000000
SELECT direction(tgeompoint '{[Point(0 0 0)@2001-01-01, Point(0 1 1)@2001-01-02,
Point(0 1 1)@2001-01-03, Point(0 0 0)@2001-01-04)}');
-- NULL
Return the temporal azimuth
azimuth(tpoint) → tfloat
The result is expressed in radians. The azimut is undefined when two succesive locations are equal and in this case a temporal gap is added.
SELECT round(degrees(azimuth(tgeompoint '[Point(0 0 0)@2001-01-01,
Point(1 1 1)@2001-01-02, Point(1 1 1)@2001-01-03, Point(0 0 0)@2001-01-04)')));
-- Interp=Step;{[45@2001-01-01, 45@2001-01-02], [225@2001-01-03, 225@2001-01-04)}
Return the temporal angular difference
angularDifference(tpoint) → tfloat
The result is expressed in degrees.
SELECT round(angularDifference(tgeompoint '[Point(1 1)@2001-01-01, Point(2 2)@2001-01-02,
Point(1 1)@2001-01-03]'), 3);
-- {0@2001-01-01, 180@2001-01-02, 0@2001-01-03}
SELECT round(degrees(angularDifference(tgeompoint '{[Point(1 1)@2001-01-01,
Point(2 2)@2001-01-02], [Point(2 2)@2001-01-03, Point(1 1)@2001-01-04]}')), 3);
-- {0@2001-01-01, 0@2001-01-02, 0@2001-01-03, 0@2001-01-04}
Return the temporal bearing
bearing({tpoint,point},{tpoint,point}) → tfloat
Notice that this function does not accept two temporal geographic points.
SELECT degrees(bearing(tgeompoint '[Point(1 1)@2001-01-01, Point(3 3)@2001-01-03]', geometry 'Point(2 2)')); -- [45@2001-01-01, 0@2001-01-02, 225@2001-01-03] SELECT round(degrees(bearing(tgeompoint '[Point(0 0)@2001-01-01, Point(2 0)@2001-01-03]', tgeompoint '[Point(2 1)@2001-01-01, Point(0 1)@2001-01-03]')), 3); -- [63.435@2001-01-01, 0@2001-01-02, 296.565@2001-01-03] SELECT round(degrees(bearing(tgeompoint '[Point(2 1)@2001-01-01, Point(0 1)@2001-01-03]', tgeompoint '[Point(0 0)@2001-01-01, Point(2 0)@2001-01-03]')), 3); -- [243.435@2001-01-01, 116.565@2001-01-03]