> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ocient.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Geospatial Functions

export const OcientGeo = "OcientGeo™";

export const OcientDataIntelligencePlatform = "OcientAIQ™ Unified Data Platform";

The {OcientDataIntelligencePlatform} has {OcientGeo} that supports three different geospatial geographies: `POLYGON`, `LINESTRING`, and `POINT`.

* A `POLYGON` can be constructed with a closed LINESTRING or an outer shell and array of inner rings.
* A `LINESTRING` represents a series of points connected by line segments. It can be constructed with either `LINESTRING` or `POINT` data types.
* A `POINT` represents a point in space defined by an (x, y) or (longitude, latitude) coordinate pair.

<Info>
  Each `LINESTRING` or `POLYGON` value can be up to a maximum of 512 MB in size. This means a `LINESTRING` or `POLYGON` can contain approximately 32 million point values.
</Info>

These supported geospatial data types require Well-Known Text (WKT) formatting. For formatting examples, see [Data Types](/data-types) or [WKT Representation of Geometry](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry#Geometric_objects). The OcientGeo functionality reference also contains examples with supported formatting and syntax.

Each geospatial geography has a number of functions and operators that can be used in SQL queries to perform analyses. Some functions apply to specific geography types. For operators specific to geospatial data types, refer to [Geospatial Operators](#geospatial-operators).

OcientGeo uses the authalic radius of the Earth, 6371007.1810824 meters, as the reference for many measurement calculations.

<Info>
  The authalic radius reference might cause slight differences in measurements compared to other geospatial systems that use a different radius definition.
</Info>

## Geospatial Operators

OcientGeo supports special operators that perform operations on two different geographies. These can be used in queries to compare geographies or calculate values based on the geographies.

| **Operator**          | **Syntax**        | **Purpose**                                                                                  |
| --------------------- | ----------------- | -------------------------------------------------------------------------------------------- |
| intersects            | `geoA && geoB`    | Returns `TRUE` if the bounding box of geography A intersects with the bounding box of B.     |
| contained             | `geoA @ geoB`     | Returns `TRUE` if the bounding box of geography A is contained within the bounding box of B. |
| equal                 | `geoA ~= geoB`    | Returns `TRUE` if the bounding box of geography A is the same as bounding box of B.          |
| contains              | `geoA ~ geoB`     | Returns `TRUE` if the bounding box of geography A contains the bounding box of B.            |
| distance              | `geoA <-> geoB`   | Returns the distance in meters between the two geography parameters.                         |
| bounding box distance | `geoA <#> geoB`   | Returns the distance in meters between the bounding box of the two geography parameters.     |
| centroid distance     | `geoA <<->> geoB` | Returns the distance in meters between the centroids of the two geography parameters.        |

## Geospatial Functions Overview

OcientGeo supports many geospatial functions that operate on POINT, LINESTRING, and POLYGON values. Each function, its expected inputs, and return type are described in the following section.

## Geospatial Filtering

Queries that involve geospatial filtering can make use of functions in the [Spatial Relationships](/spatial-relationships) section.

To optimize these queries, OcientGeo provides a `SPATIAL` index that you can apply to columns with geospatial data types. For details about the `SPATIAL` index, see [Secondary Indexes](/secondary-indexes#spatial-index-type).

## [Attribute Functions](/attribute-functions)

Attribute functions return descriptive information on the specified data set.

* ST\_COORDDIM
* ST\_DIMENSION
* ST\_GEOMETRYTYPE
* ST\_ISEMPTY
* ST\_MEMSIZE
* ST\_NDIMS
* ST\_NDIMENSION
* ST\_NPOINTS
* ST\_NUMPOINTS
* ST\_SRID
* ST\_X
* ST\_XMAX
* ST\_XMIN
* ST\_Y
* ST\_YMAX
* ST\_YMIN

## [Conversion Functions](/conversion-functions)

Conversion functions transform a specified operand to a different data type.

* ST\_ASBINARY
* ST\_ASWKB
* ST\_ASGEOJSON
* ST\_ASEWKT
* ST\_ASLATLONTEXT
* ST\_ASTEXT
* ST\_ASWKT
* ST\_GEOHASH

## [Linestring Constructors](/linestring-constructors)

LINESTRING constructors use geospatial data to create a LINESTRING object.

* ST\_LINEFROMTEXT
* ST\_LINEFROMGEOJSON
* ST\_LINEFROMWKB
* ST\_LINEFROMEWKT
* ST\_LINESTRING
* ST\_MAKELINE

## [Linestring Functions](/linestring-functions)

LINESTRING functions can perform alterations or access descriptive information on LINESTRING objects.

* ST\_ADDPOINT
* ST\_ENDPOINT
* ST\_LINEINTERPOLATEPOINT
* ST\_LINELOCATEPOINT
* ST\_LINESUBSTRING
* ST\_POINTN
* ST\_REMOVEPOINT
* ST\_SETPOINT
* ST\_STARTPOINT

## [Point Constructors](/point-constructors)

POINT constructors use geospatial data to create a POINT object.

* ST\_CENTROID
* ST\_GEOGPOINT
* ST\_MAKEPOINT
* ST\_POINT
* ST\_POINTFROMEWKT
* ST\_POINTFROMGEOHASH
* ST\_POINTFROMGEOJSON
* ST\_POINTFROMTEXT
* ST\_POINTFROMWKB

## [Polygon Constructors](/polygon-constructors)

POLYGON constructors use geospatial data to create a POLYGON object.

* ST\_FORCECCW
* ST\_MAKEPOLYGON
* ST\_POLYGON
* ST\_POLYGONFROMGEOJSON
* ST\_POLYGONFROMWKB
* ST\_POLYGONFROMEWKT
* ST\_POLYGONFROMTEXT
* ST\_WHOLEEARTH

## [Spatial Measurement](/spatial-measurement)

Spatial measurement functions can perform basic calculations on geospatial data, such as measuring the distance between two POINT objects or the area of a POLYGON object.

* ST\_AREA
* ST\_ANGLE
* ST\_AZIMUTH
* ST\_DISTANCE
* ST\_DISTANCESPHERE
* ST\_DISTANCESPHEROID
* ST\_EUCLIDEANDISTANCE3D
* ST\_HAUSDORFFDISTANCE
* ST\_LENGTH
* ST\_LENGTH2D
* ST\_MINIMUMDISTANCETOSURFACE
* ST\_MAXDISTANCE
* ST\_PERIMETER
* ST\_PERIMETER2D

## [Spatial Operators](/spatial-operators)

Spatial operators perform geometry calculations on geospatial data to return a different type of geospatial data.

* ST\_BOUNDINGDIAGONAL
* ST\_BUFFER
* ST\_CLOSESTPOINT
* ST\_CONVEXHULL
* ST\_DIFFERENCEARRAY
* ST\_ENVELOPE
* ST\_EXPAND
* ST\_EXTERIORRING
* ST\_FLIPCOORDINATES
* ST\_FORCE2D
* ST\_INTERIORRINGN
* ST\_INTERSECTALL
* ST\_INTERSECTIONARRAY
* ST\_LONGESTLINE
* ST\_MAKEENVELOPE
* ST\_MINIMUMBOUNDINGCIRCLE
* ST\_MULTIDIFFERENCEARRAY
* ST\_MULTIINTERSECTIONARRAY
* ST\_MULTISYMDIFFERENCEARRAY
* ST\_MULTIUNIONARRAY
* ST\_NRINGS
* ST\_NUMINTERIORRING
* ST\_NUMINTERIORRINGS
* ST\_POINTONSURFACE
* ST\_PROJECT
* ST\_REDUCEPRECISION
* ST\_REMOVEREPEATEDPOINTS
* ST\_REVERSE
* ST\_SEGMENTIZE
* ST\_SHORTESTLINE
* ST\_SIMPLIFY
* ST\_SIMPLIFYARRAY
* ST\_SNAPTOGRID
* ST\_SYMDIFFERENCEARRAY
* ST\_UNIONARRAY

## [Spatial Relationships](/spatial-relationships)

Spatial relationship functions use arguments to test for different types of spatial relationships. 

* ST\_CLUSTERDBSCAN
* ST\_CONTAINS
* ST\_CONTAINSPROPERLY
* ST\_COVERS
* ST\_COVEREDBY
* ST\_CROSSES
* ST\_DISJOINT
* ST\_DWITHIN
* ST\_EQUALS
* ST\_INTERSECTS
* ST\_ISCCW
* ST\_ISPOLYGONCCW
* ST\_ISPOLYGONCW
* ST\_ISCLOSED
* ST\_ISRING
* ST\_ISSIMPLE
* ST\_ISVALID
* ST\_OVERLAPS
* ST\_POINTINSIDECIRCLE
* ST\_RELATE
* ST\_TOUCHES
* ST\_WITHIN

## [Spatiotemporal Measurement](/spatiotemporal-measurement)

Spatiotemporal measurement functions can perform basic calculations on geospatial data paired with TIMESTAMP data.

* ST\_DISTANCE
* ST\_MAXDISTANCE
* ST\_TOTALSECONDSININTERSECTION

## [Spatiotemporal Operators](/spatiotemporal-operators)

Spatiotemporal operators perform calculations on geospatial data using an array of TIMESTAMP arguments.

* ST\_LONGESTLINE
* ST\_LINEGETALLTIMESATPOINT
* ST\_LINEGETPOINTATTIME
* ST\_LINEGETTIMEATPOINT
* ST\_INTERSECTION
* ST\_SHORTESTLINE

## Related Videos

[At the Whiteboard with Ocient: Geospatial Analytics](https://youtu.be/tIlTpbCP0Rg)
