Spatial Operators
OcientGeo™ spatial noperators perform geometry calculations on geospatial data to return a different type of geospatial data.
ST_BOUNDINGDIAGONAL
Returns the diagonal LINESTRING from the minimum point to the maximum point of the bounding box that ST_ENVELOPE returns.
Syntax
Example
Output: LINESTRING(1 2,1 3)
ST_BUFFER
Returns a geography that contains all points where the distance from the geography is less than or equal to the specified distance. The function simplifies the geometry before buffering unless you specify the simplification_tolerance argument with a zero or negative value.
The output of the function is an array of polygons. For POINT and LINESTRING data types, the returned array contains one polygon only.
Syntax
Example
Output:
[POLYGON((2.202700241764562E-18 -0.017986411844962975, 1.0179863625702694 -0.0179863616840571, 1.0179892379654352 1.031486286416526, 1.009550207729886 1.0349816974070565, -0.03498171178141835 -0.009548649645081482, -0.03148633724650228 -0.01798632287046757, 2.202700241764562E-18 -0.017986411844962975))]
ST_CLOSESTPOINT
Returns the two-dimensional POINT of one specified geospatial object that is closest to a second specified geospatial object. This function works with any geospatial type.
If either geospatial argument is empty, the function returns NULL.
Syntax
Example
Output: POINT(2,3)
ST_CONVEXHULL
Returns a POLYGON representing the convex hull of the input geometry.
The convex hull is the smallest convex geometry that encloses the input geometry. If the geo argument is empty, the function returns an empty POLYGON.
Syntax
Example
Output: POLYGON((0.0 0.0, 1.0 0.0, 1.0 1.0, 0.0 1.0, 0.0 0.0))
ST_DIFFERENCEARRAY
Returns an array containing any geospatial objects that are present in the first specified geospatial argument that are not found in the second geospatial argument.
Syntax
Example
In this example, the function returns LINESTRING(2.0 2.0, 3.0 3.0) because that portion of the first LINESTRING argument is not present in the second argument.
Output: [LINESTRING(2.0 2.0, 3.0 3.0)]
ST_ENVELOPE
Returns a POLYGON that represents the minimum bounding box for the specified geography. If the specified argument is empty, the function returns an empty POLYGON.
A single POINT argument results in a single POINT.
Syntax
Example
Output: POLYGON((0 0,10 0,10 10,0 10,0 0))
ST_EXPAND
Returns the bounding box of a specified geospatial value, which is expanded by a specified length. The unit of length is in meters.
Syntax
Example
Output: POLYGON((0.99 0.99, 1.33 0.99, 1.66 0.99, 2.01 0.99, 2.00 2.00, 1.66 2.00, 1.33 2.00, 0.99 2.00, 0.99 0.99))
ST_EXTERIORRING
Returns a LINESTRING that represents the exterior ring of a provided POLYGON value. If you specify a geography value that is not a POLYGON, the function returns NULL.
Syntax
Example
Output: LINESTRING(1.0 1.0, 3.0 1.0, 2.0 2.0, 1.0 1.0)
ST_FLIPCOORDINATES
Returns a new geographic object with the X and Y coordinates switched using the specified argument. The return type is the same as the specified type.
Syntax
Example
Output: POINT(3.0 1.0)
ST_FORCE2D
Convert a geographic object into a two-dimensional geography. The output representations only have the X and Y coordinates.
The returned type is the same as the specified type.
Syntax
Example
Output: POINT(1.0 1.0)
ST_INTERIORRINGN
Returns a LINESTRING representing the interior ring of the specified POLYGON, which is specified by its index. (1-indexed)
Returns NULL if the index is out of range, or if you specify a non-POLYGON geography.
Syntax
Example
Output: LINESTRING(1 2)
ST_INTERSECTALL
Returns the intersection of all geographies in the specified array. All geographies in the array must be the same type. The ST_INTERSECTALL function ignores NULL values in the array. The output geography has the same type as the input geometries.
Syntax
Example
Output: POINT[]
ST_INTERSECTIONARRAY
Returns a geography that represents the point-set intersection of two geographies.
If the two geographies are of different types, the function returns an array of the smallest geography. For example, if geo1 is a POINT, and geo2 is a POLYGON, the function returns an array of POINT values.
Syntax
Example
This example compares two polygons to find any intersections. Because both objects are POLYGON types, the result is also a POLYGON containing all intersection points.
Output: [POLYGON((1, 2))]
ST_LONGESTLINE
Returns the longest LINESTRING between two specified geospatial arguments.
Syntax
Example
Output: LINESTRING(0.0 3.0, 2.0 3.0)
To use ST_LONGESTLINE as a spatiotemporal function to calculate the longest line between two points at a concurrent time, see the ST_LONGESTLINE function.
ST_MAKEENVELOPE
Alias for ST_ENVELOPE(ST_LINESTRING(ST_POINT(xmin, ymin), ST_POINT(xmax, ymax))).
Returns a POLYGON with vertices representing the minimum bounding box for the specified coordinates.
Syntax
Example
Output: POLYGON((0.0 0.0, 10.0 0.0, 10.0 10.0, 0.0 10.0, 0.0 0.0))
ST_MINIMUMBOUNDINGCIRCLE
Returns the smallest circle POLYGON that contains the specified geographic object.
The function requires an additional argument to define the number of segments for inclusion in each quarter of the returned circle.
Syntax
Example
Output: POLYGON((1.49 2.91, 0.27 0.79, 2.72 0.79, 1.49 2.91))
ST_MULTIDIFFERENCEARRAY
Returns an array of geographies representing the parts of the union of the geographies in the first array that do not intersect with the union of geographies in the second array.
This operation is not symmetric, meaning ST_MULTIDIFFERENCEARRAY(array1, array2) does not produce the same results as ST_MULTIDIFFERENCEARRAY(array2, array1) unless both arrays are identical.
The function ignores NULL types. For types besides NULL, all geographies in both arrays must be of the same type.
The output geographies are the same type as the input geographies.
Syntax
Example
Output: ['POINT(0.0 0.0)']
ST_MULTIINTERSECTIONARRAY
When you specify two arrays of geospatial objects, this function returns an array of any intersections. The function treats each specified array as a union of all its geospatial values.
All geographies in both arrays must be of the same type, not counting NULL values, which the function ignores.
The output geographies are the same type as the input geographies.
Syntax
Example
Output: ['POINT(1.0 1.0)']
ST_MULTISYMDIFFERENCEARRAY
Alias for ST_MULTIUNIONARRAY(array1, array2) - ST_MULTIINTERSECTIONARRAY(array1, array2).
When you specify two arrays of geospatial objects, this function returns an array of any geospatial values that do not intersect. The function treats each specified array as a union of all its geospatial values.
All geographies in both arrays must be of the same type, not counting NULL values, which the function ignores.
The output geographies are the same type as the input geographies.
Syntax
Example
Output: ['POINT(0.0 0.0)','POINT(2.0 2.0)']
ST_MULTIUNIONARRAY
When you specify two arrays of geospatial objects, this function returns one array that represents a union of all geographies in both arrays.
All geographies in both arrays must be the same type. The function ignores NULL values in the arrays. The output geographies are the same type as the input geographies.
Syntax
Example
Output: ['POINT(1.0 1.0)','POINT(2.0 2.0)','POINT(0.0 0.0)']
ST_NRINGS
Returns the number of rings of the specified POLYGON, including both interior and exterior rings. If you specify a geography object that is not a POLYGON, this function returns 0.
Syntax
Example
Output: 1
ST_NUMINTERIORRINGS or ST_NUMINTERIORRING
Returns the number of interior rings of the specified POLYGON. If you specify a geography object that is not a POLYGON, this function returns 0.
Syntax
Example
Output: 1
ST_POINTONSURFACE
Returns a POINT guaranteed to intersect the specified geospatial object.
Syntax
Example
Output: POINT(1.0 1.0)
ST_PROJECT
Returns a POINT by projecting a distance and an azimuth value from the specified starting POINT value. The distance must be in meters, and azimuth must be in radians.
Syntax
Example
Output: POINT(0.99 3.00)
ST_REDUCEPRECISION
Returns a new geospatial object with all POINT values rounded to the specified decimal precision.
Syntax
Example
Output**:** POINT(1.2 1.3)
ST_REMOVEREPEATEDPOINTS
Returns a new geospatial object with no repeated POINT values. The returned type is the same as the specified type.
Syntax
Example
Output: LINESTRING(1.0 2.0, 2.0 1.0, 1.0 0.0)
ST_REVERSE
Returns a new geospatial object with the vertexes reversed. The returned type is the same as the specified type.
Syntax
Example
Output: LINESTRING(1.0 10.0, 1.0 2.0)
ST_SEGMENTIZE
Returns a geospatial object that the function modifies to have no segment longer than the specified max_segment_length in meters.
Syntax
Example
Output: POLYGON((1.0 1.0, 2.0 1.0, 2.0 2.0, 1.49 1.50, 1.0 1.0))
ST_SHORTESTLINE
Returns the shortest LINESTRING between two specified geospatial arguments.
Syntax
Example
Output: LINESTRING(0.0 3.0, 4.0 3.0)
To use ST_SHORTESTLINE as a spatiotemporal operator to calculate the shortest line between two points at a concurrent time, see the ST_SHORTESTLINE function in the Spatiotemporal section.
ST_SIMPLIFY
Returns a simplified version of the specified geography, which is either a POINT or LINESTRING.
The function simplifies the input geography by replacing nearly straight edges that contain multiple points with a single straight edge. The input geography does not change by more than the specified tolerance, which you specify as a DOUBLE in meters.
Syntax
Example
Output: LINESTRING(0 0, 2 0)
ST_SIMPLIFYARRAY
Returns a POLYGON array that represents a simplified version of the specified geography, which is either a POINT, LINESTRING, or POLYGON.
The function simplifies the input geography by replacing nearly straight edges that contain multiple points with a single straight edge. The input geography does not change by more than the specified tolerance, which you specify as a DOUBLE in meters.
Syntax
Example
In this example, ST_SIMPLIFYARRAY evaluates a POLYGON with an outer ring of 13 points and an inner ring with four points. The example sets a tolerance argument of 10,000 meters, meaning that is the maximum distance that the function simplifies.
Output*:*[POLYGON((0.0 0.5000000762285838, 1.0 0.500000076228584, 1.0 1.0, 0.0 1.0, 0.0 0.5000000762285838)), POLYGON((1.0 0.4998004375649452, 0.5 0.4, 0.0 0.4998004375649452, 0.0 0.0, 1.0 0.0, 1.0 0.4998004375649452))]
As shown in the output, the ST_SIMPLIFYARRAY function has reduced the size of the outer POLYGON from 13 points to 5.
Note that the function actually increases the number of points in the inner ring, going from four to six. The increase is due to how close the inner ring is to the edges of the outer ring. Taken altogether, the function still reduced the total number of points in the POLYGON.
ST_SNAPTOGRID
Returns a new geography value with all POINT values rounded to the specified precision. This function is similar to ST_REDUCEPRECISION but it allows you to specify the precision for the x and y coordinates separately.
Syntax
Example
Output: POINT(1.0 3.1)
ST_SYMDIFFERENCEARRAY
Returns a geographic array that contains the parts that are not common between two geographic objects, geo1 and geo2.
Syntax
Example
Output: [LINESTRING(2.0 2.0, 3.0 3.0)]
ST_UNIONARRAY
Performs a union of the input geography values to produce a geographic array.
Syntax
Example
Output: ['LINESTRING(0.0 0.0, 1.0 1.0, 2.0 2.0, 3.0 3.0)']

