---
title: Spatiotemporal Measurement
slug: bGW9YFiw2BViqXK42gFcL
description: Utilize spatiotemporal measurement functions in OcientGeo for comprehensive analysis of space-time data.
docTags: 
createdAt: Mon Aug 01 2022 19:56:34 GMT+0000 (Coordinated Universal Time)
updatedAt: Mon Mar 30 2026 18:52:40 GMT+0000 (Coordinated Universal Time)
---

OcientGeo™ spatiotemporal measurement functions can perform basic calculations on geospatial data that is paired with TIMESTAMP data.

# ST\_DISTANCE

Returns the two-dimensional interpolated minimum simultaneous distance between two `LINESTRING-TIMESTAMP` array pairs in the specified unit of measurement.  &#x20;

If any argument is NULL or empty, the function returns NULL. If either `LINESTRING-TIMESTAMP` array pair has a mismatched number of points and timestamps, the function returns an error.&#x20;

Behavior is undefined if either timestamp array is not monotonically increasing.

```sql
ST_DISTANCE(geo1, ts_arr1, geo2, ts_arr2, units [, use_spheroid] )
```

| **Argument**   | **Data** **Type** | **Description**                                                                                                                                                                            |
| -------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `geo1`         | `LINESTRING`      | A geospatial object to be evaluated for its minimum cotemporal distance from `geo2`.                                                                                                       |
| `ts_arr1`      | `TIMESTAMP ARRAY` | A timestamp array that is paired with `geo1`.                                                                                                                                              |
| `geo2`         | `LINESTRING`      | A geospatial object to be evaluated for its minimum cotemporal distance from `geo1`.                                                                                                       |
| `ts_arr2`      | `TIMESTAMP ARRAY` | A timestamp array that is paired with `geo2`.                                                                                                                                              |
| `units`        | `STRING`          | The unit of measurement used for the minimum cotemporal distance. <br />Accepted options include `'FEET'`, `'KILOMETERS'`, `'MILES'`, or `'METERS'`.<br />The default value is `'METERS'`. |
| `use_spheroid` | `BOOLEAN`         | Optional. <br /><br />If you set this argument to `TRUE`, this function uses a spheroid model instead of a spherical model.<br /> <br />The default value is `FALSE`.                      |

**Example**

```sql
SELECT ST_DISTANCE(
        ST_LINESTRING('linestring(0 0,0 12)'),
        TIMESTAMP [](
            '2020-07-04 07:00:00.000000000',
            '2020-07-04 11:00:00.000000000'),
        ST_LINESTRING('linestring(0 0,6 0)'),
        TIMESTAMP [](
            '2020-07-04 08:00:00.000000000',
            '2020-07-04 10:00:00.00000000'),
        'MILES',
        TRUE);
```

*Output*: `206.124`

:::hint{type="info"}
To use ST\_DISTANCE as a spatial function to calculate the minimum distance between two points, see the [ST\_DISTANCE](<./Spatial Measurement.md>) function in the Spatial Measurement section.&#x20;
:::

# ST\_MAXDISTANCE

Returns the two-dimensional interpolated maximum cotemporal distance between two `LINESTRING-TIMESTAMP` array pairs in the specified unit of measurement.  &#x20;

If any argument is NULL or empty, the function returns NULL. If either `LINESTRING-TIMESTAMP` array pair has a mismatched number of points and timestamps, the function returns an error.&#x20;

Behavior is undefined if either timestamp array is not monotonically increasing.

```sql
ST_MAXDISTANCE(geo1, ts_arr1, geo2, ts_arr2, units [, use_spheroid] )
```

| **Argument**   | **Data** **Type** | **Description**                                                                                                                                                                            |
| -------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `geo1`         | `LINESTRING`      | A geospatial object to be evaluated for its maximum cotemporal distance from `geo2`.                                                                                                       |
| `ts_arr1`      | `TIMESTAMP ARRAY` | A `TIMESTAMP ARRAY` that is paired with `geo1`.                                                                                                                                            |
| `geo2`         | `LINESTRING`      | A geospatial object to be evaluated for its maximum cotemporal distance from `geo1`.                                                                                                       |
| `ts_arr2`      | `TIMESTAMP ARRAY` | A `TIMESTAMP ARRAY` that is paired with `geo2`.                                                                                                                                            |
| `units`        | `STRING`          | The unit of measurement used for the maximum cotemporal distance. <br />Accepted options include `'FEET'`, `'KILOMETERS'`, `'MILES'`, or `'METERS'`.<br />The default value is `'METERS'`. |
| `use_spheroid` | `BOOLEAN`         | Optional. <br /><br />If you set this argument to `TRUE`, this function uses a spheroid model instead of a spherical model. <br /><br />The default value is `FALSE`.                      |

**Example**

```sql
SELECT ST_MAXDISTANCE(
    ST_LINESTRING('linestring(0 0,0 12)'), 
        TIMESTAMP[]('2020-07-04 07:00:00.000000000', '2020-07-04 11:00:00.000000000'), 
    ST_LINESTRING('linestring(0 0,6 0)'), 
        TIMESTAMP[]('2020-07-04 08:00:00.000000000', '2020-07-04 10:00:00.00000000'), 
    'MILES', 
    TRUE);
```

*Output*: `743.83`

:::hint{type="info"}
To use ST\_MAXDISTANCE as a spatial function to calculate the maximum distance between two points, see the [ST\_MAXDISTANCE](<./Spatial Measurement.md>) function in the Spatial Measurement section.&#x20;
:::

# ST\_TOTALSECONDSININTERSECTION

Returns the total number of seconds spent in the intersection result calculated by the spatiotemporal version of [ST\_INTERSECTION](<./Spatiotemporal Operators.md>).&#x20;

Execute this function only with the result from ST\_INTERSECTION. If the input is an empty, correctly typed tuple, this function returns 0 seconds. If the input is NULL, this function returns NULL.

```sql
ST_TOTALSECONDSININTERSECTION(tpl)
```

| **Argument** | **Data** **Type**                      | **Description**                                                                             |
| ------------ | -------------------------------------- | ------------------------------------------------------------------------------------------- |
| `tpl`        | Tuple of `LINESTRING-TIMESTAMP` pairs  | A tuple of `LINESTRING-TIMESTAMP` pairs used to evaluate how long an intersection existed.  |

**Example**

```sql
SELECT ST_TOTALSECONDSININTERSECTION(
    ST_INTERSECTION(
        ST_LINESTRING('LINESTRING(1 1,2 2,1 1)'), 
            TIMESTAMP[](
                '2020-07-04 07:00:00.000000000', 
                '2020-07-04 11:00:00.000000000', 
                '2020-07-04 12:00:00.000000000'), 
        ST_LINESTRING('LINESTRING(2 2,1 1)')));
```

*Output*: `18000.0`

# Related Links

[Geospatial Data Types](<././Data Types.md>)

[Spatiotemporal Operators](<./Spatiotemporal Operators.md>)
