spatial relationship functions use arguments to test for different types of spatial relationships.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.
ST_CLUSTERDBSCAN
Returns the cluster number for each input geography based on a two-dimensional implementation of the density-based spatial clustering of applications with noise (DBSCAN) algorithm. This function is a window function because the resulting value for an individual row depends on other rows and not just itself. No frame specification is allowed. This function supports sort orders, but it is unnecessary unless deterministic resolution of tie-breaking in cluster determination is required. This tie-breaking happens only in situations where a point on the boundary of a cluster is equally valid for multiple clusters. In these cases, the result depends on the sort order of the data. For this reason, you might want to sort the data to force the deterministic behavior by using anORDER BY in the OVER clause.
The function returns NULL for any row not included in a cluster.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo | POINT, LINESTRING, or POLYGON | A geospatial object to be grouped into a cluster based on the DBSCAN algorithm. |
eps | DOUBLE | A numeric argument that controls the separation between objects before they are considered a new cluster. The eps argument is in meters. |
min_neighbors | BIGINT | The minimum number of objects within the appropriate distance of each other that need to exist before it is considered a cluster. |
SQL
1
ST_CONTAINS
ReturnsTRUE if the first geographic argument, geo1, contains the second geographic argument, geo2.
geo1 contains geo2 only if all of these criteria are met:
- No
POINTvalues ofgeo2are located at the exterior ofgeo1. - At least one
POINTin the interior ofgeo2lies in the interior ofgeo1.
POINT values in a LINESTRING are interior, except for the endpoints, which are regarded as exterior boundaries.
If either geo1 or geo2 is NULL, then the function returns NULL.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo2.The POINT values in geo1 are evaluated to determine if they are contained within geo2. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo1.The POINT values in geo2 are evaluated to determine if they are contained within geo1. |
SQL
true
ST_CONTAINSPROPERLY
This function is similar to ST_CONTAINS, but it has stricter criteria. Returns true ifgeo2 lies entirely in the interior of geo1 and does not intersect or touch the boundary or exterior points.
Returns NULL if either geo1 or geo2 is NULL.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo2. The POINT values in geo1 are evaluated to determine if they are contained within geo2. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo1. The POINT values in geo2 are evaluated to determine if they are contained within geo1. |
POLYGON representing a simple square (0 0, 1 0, 1 1, 0 1). The second geographic object is a small LINESTRING that spans from the point (0.25 0.25) to the point (0.75 0.75).
Because the line is located entirely within the polygon, never touching its boundaries, the function evaluates to true.
SQL
TRUE
The second geographic object is slightly altered in this example, where the line spans from (0 0) to (1 1). Both of these endpoints touch the boundaries of the polygon, so the function now evaluates to false.
SQL
FALSE
ST_COVERS
ReturnsTRUE if no POINT in geo2 is outside of geo1.
Returns NULL if either geo1 or geo2 is NULL.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo2. The POINT values in geo2 are evaluated to determine if they are contained within geo2. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo1. The POINT values in geo2 are evaluated to determine if they are contained within geo1. |
SQL
TRUE
ST_COVEREDBY
This function operates similarly to ST_COVERS, except the arguments are interchanged. ReturnsTRUE if no POINT in geo1 is outside of geo2.
Returns NULL if either geo1 or geo2 is NULL.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo2. The POINT values in geo1 are evaluated to determine if they are contained within geo2. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo1 The POINT values in geo1 are evaluated to determine if they are contained within geo2. |
SQL
TRUE
ST_CROSSES
ReturnsTRUE if two geospatial objects meet this criteria:
- The intersection of the geospatial interiors is not empty.
- The intersection is not equal to
geo1orgeo2. - Neither geospatial object is a single
POINT.
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo2 to evaluate whether they cross. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo1 to evaluate whether they cross. |
SQL
TRUE
ST_DISJOINT
Returnstrue if the specified geographies have no intersection, including boundaries. Both geographic arguments can be different types.
This function is the opposite of the ST_INTERSECTS function.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo2 to evaluate whether they intersect. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo1 to evaluate whether they intersect. |
SQL
TRUE
ST_DWITHIN
ReturnsTRUE if the geographies are within a specified distance in meters.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo2 to evaluate whether they are within the specified distance distance_meters. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo1 to evaluate whether they are within the specified distance distance_meters. |
distance_meters | DOUBLE | A numeric value that represents the number of meters to evaluate the distance between geo1 and geo2. |
SQL
FALSE
ST_EQUALS
ReturnsTRUE if both geographies are spatially equal.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo2 to evaluate whether they are equal. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo1 to evaluate whether they are equal. |
SQL
True
ST_INTERSECTS
ReturnsTRUE if the specified geographies intersect, including boundaries.
This function is the opposite of the ST_DISJOINT function.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo2 to evaluate whether they intersect. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo1 to evaluate whether they intersect. |
SQL
FALSE
ST_ISCCW
Alias for ST_ISPOLYGONCCW.ST_ISCLOSED
ReturnsTRUE if an input LINESTRING has starting and ending points that are equal.
If you specify a POLYGON or POINT value, the function returns true if the specified geography is not empty.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
line | POINT, LINESTRING, or POLYGON | If you specify a LINESTRING object, the function evaluates it to determine whether its starting and ending points are equal. If you specify a POLYGON or POINT value, the function returns true if the specified geography is not empty. |
SQL
TRUE
ST_ISPOLYGONCW
Alias forBOOLNOT(ST_ISCCW(poly)).
Returns TRUE if an input POLYGON has an exterior that is clockwise.
If the POLYGON argument is empty, this function returns TRUE. If the argument is NULL, this function returns NULL.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
poly | POLYGON | A POLYGON object to evaluate to determine whether its point values align in a clockwise direction. |
SQL
FALSE
ST_ISPOLYGONCCW
Alias for ST_ISCCW. ReturnsTRUE if an input POLYGON has an exterior that is counter-clockwise.
If the POLYGON argument is empty, this function returns TRUE. If the argument is NULL, this function returns NULL.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
poly | POLYGON | A POLYGON object to evaluate to determine whether its point values align in a counter-clockwise direction. |
SQL
TRUE
ST_ISRING
ReturnsTRUE if the specified LINESTRING is closed and does not intersect itself. This function is equivalent to evaluating both ST_ISCLOSED and ST_ISSIMPLE.
If you specify a value other than LINESTRING, the function throws an error.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
line | LINESTRING | A LINESTRING object to evaluate to determine whether its starting and ending points are equal and whether it has no intersections. |
SQL
TRUE
ST_ISSIMPLE
ForLINESTRING values, this function returns FALSE if any line segments intersect anywhere besides the endpoints.
For POLYGON values, the function returns FALSE if either the exterior ring or any interior hole is not simple.
For POINT values, the function always returns TRUE.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo | POINT, LINESTRING, or POLYGON | A geospatial object to evaluate to determine if any points intersect. For LINESTRING values, this function returns FALSE if any line segments intersect anywhere besides the endpoints. For POLYGON values, the function returns FALSE if either the exterior ring or any interior hole is not simple. For POINT values, the function always returns TRUE. |
SQL
TRUE
ST_ISVALID
ReturnsTRUE if the specified geospatial value is a well-formed and valid geography according to the OGC standards.
LINESTRING values are not valid if they are composed of more than one POINT with the same coordinates.
POLYGON values are valid if they are composed of one external ring (shell) and zero or more internal rings. A ring is a LINESTRING where only the first and last POINT intersect each other. All internal rings need to be contained inside the shell, and none of the rings should intersect with each other in more than one POINT.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo | POINT, LINESTRING, or POLYGON | A geospatial object to evaluate to determine if it is a well-formed geography. |
SQL
TRUE
ST_OVERLAPS
ReturnsTRUE if both geographic arguments are of the same dimension and intersect, but neither contains the other. Returns NULL if either geo1 or geo2 is NULL.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object for evaluation to determine if it is shaped similarly and intersects geo2. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object for evaluation to determine if it is shaped similarly and intersects geo1. |
SQL
TRUE
ST_POINTINSIDECIRCLE
ReturnsTRUE if the geographic object is inside a circle centered at the specified point coordinates and with the specified radius.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo | POINT, LINESTRING, or POLYGON | A geospatial object for evaluation to determine if it is contained within a circle of the specified dimensions. |
center_x | DOUBLE | The x coordinate of the center of the circle to evaluate. |
center_y | DOUBLE | The y coordinate of the center of the circle to evaluate. |
circle_radius | DOUBLE | The radius in meters of the circle to evaluate. |
SQL
TRUE
ST_RELATE
Returns the DE-9IM intersection string that represents the nature of the intersection with the specified geographies. If you specify an intersection pattern as the third argument, this function returnsTRUE if the intersection of the geographies satisfies the pattern and FALSE otherwise.
Syntax
SQL
| Parameter | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object to relate with geo2. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object to relate with geo1. |
intersectionPattern | STRING | Optional. Intersection pattern to query the nature of the intersection of geo1 and geo2.Must contain exactly 9 characters, corresponding to the component (interior, boundary, or exterior) intersections considered by DE-9IM. Supported characters are: * T — Components intersect.* F — Components do not intersect.* 0 — Component intersection is zero-dimensional.* 1 — Component intersection is 1-dimensional.* 2 — Component intersection is 2-dimensional.* * — Specify no restriction on the component intersection. |
(0.0, 0.0) and the line from -1 0 to 1 0. This function returns the DE-9IM string 0FFFFF102, which means that the boundaries do not intersect at all, but there is evidence of an intersection at the zero, one, and two-dimensional spaces.
SQL
0FFFFF102
Determine whether the intersection between the point (0.0, 0.0) and the line from -1 0 to 1 0 follows the DE-9IM pattern string TF*FFF102. This function returns TRUE, which means the nature of the intersection between these two geographies conforms to this pattern.
SQL
TRUE
ST_TOUCHES
ReturnsTRUE if the only POINT values in common between the two geographic arguments lie in the union of their boundaries.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object for evaluation to determine if it touches geo2. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object for evaluation to determine if it touches geo1. |
SQL
TRUE
ST_WITHIN
ReturnsTRUE if the geography specified by the first argument is fully inside the geography specified by the second argument.
ST_WITHIN(geo1, geo2) is equivalent to ST_CONTAINS(geo2, geo1). For details, see ST_CONTAINS.
Syntax
SQL
| Argument | Data Type | Description |
|---|---|---|
geo1 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo2 to evaluate whether it is fully inside this second geography. |
geo2 | POINT, LINESTRING, or POLYGON | A geospatial object to be compared to geo1 to evaluate whether it contains the first geography. |
SQL
true

