Geospatial Functions
The has 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.
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.
These supported geospatial data types require Well-Known Text (WKT) formatting. For formatting examples, see Data Types or WKT Representation of Geometry. 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.
OcientGeo uses the authalic radius of the Earth, 6371007.1810824 meters, as the reference for many measurement calculations.
The authalic radius reference might cause slight differences in measurements compared to other geospatial systems that use a different radius definition.
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. |
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.
Queries that involve geospatial filtering can make use of functions in the Spatial Relationships section.
To optimize these queries, OcientGeo provides a SPATIAL index that you can apply to columns with geospatial data types. For more information on the SPATIAL index, see Secondary Indexes.
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 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 use geospatial data to create a LINESTRING object.
- ST_LINEFROMTEXT
- ST_LINEFROMGEOJSON
- ST_LINEFROMWKB
- ST_LINEFROMEWKT
- ST_LINESTRING
- ST_MAKELINE
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 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 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 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_HAUSDORFFDISTANCE
- ST_LENGTH
- ST_LENGTH2D
- ST_MAXDISTANCE
- ST_PERIMETER
- ST_PERIMETER2D
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 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 functions can perform basic calculations on geospatial data that is paired with TIMESTAMP data.
- ST_DISTANCE
- ST_MAXDISTANCE
- ST_TOTALSECONDSININTERSECTION
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