Geospatial Functions
Geospatial functions are a collection of functions used to handle and manipulate three-dimensional spatial data.
CnosDB uses WKT (Well-known text) to support geospatial type (Geometry) data queries.
Please refer to Geospatial Types for supported types
<geometry tag> <wkt data>
<geometry tag> ::= POINT | LINESTRING | POLYGON | MULTIPOINT |
MULTILINESTRING | MULTIPOLYGON | GEOMETRYCOLLECTION
<wkt data> ::= <point> | <linestring> | <polygon> | <multipoint> |
<multilinestring> | <multipolygon> | <geometrycollection>
| Geometry types | image | Example |
|---|---|---|
Point | POINT (30 10) | |
LineString | LINESTRING (30 10, 10 30, 40 40) | |
Polygon | POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10)) | |
POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30)) | ||
MultiPoint | MULTIPOINT ((10 40), (40 30), (20 20), (30 10)) | |
MULTIPOINT (10 40, 40 30, 20 20, 30 10) | ||
MultiLineString | MULTILINESTRING ((10 10, 20 20, 10 40), (40 40, 30 30, 40 20, 30 10)) | |
MultiPolygon | MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5))) | |
MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20))) | ||
GeometryCollection | GEOMETRYCOLLECTION (POINT (40 10), LINESTRING (10 10, 20 20, 10 40), POLYGON ((40 40, 20 45, 45 30, 40 40))) |
ST_AsBinary
Return the spatial geometry object Geometry in WKB format.
ST_AsBinary(geometry)
View ST_AsBinary Example
ST_GeomFromWKB
Convert Well-known Binary (WKB) format binary to Geometry type
ST_GeomFromWKB(wkb)
View ST_GeomFromWKB Example
ST_Distance
Returns the minimum Euclidean distance between the 2D projections of two geometric shapes.
ST_Distance(geometry1, gemometry2)
View ST_Distance Example
ST_Area
Returns the Cartesian area of the 2D projection of the geometric object.The unit of area is the same as the unit used to represent the coordinates of the input geometry. For Point, LineString, MultiPoint, and MultiLineString, Line, this function returns 0. For a collection of geometric shapes, it returns the sum of the areas of the shapes in the collection.
Some geometric shapes do not support area calculation, calculating the area of these geometric objects will return 0, such as: Point, MultiPoint, LineString, MultiLineString, Line. If the parameter content format is invalid, the return value is NULL.
ST_Area(geometry)
View ST_Area Example
ST_Equals
Compare two geometric shapes, if two geometric shapes are exactly the same, return true.
ST_Equals(A, B) is equivalent to ST_Within(A, B) && ST_Within(B, A)
ST_Equals(A, B)
View ST_Area Example
ST_Contains
If geometric object A contains geometric object B, return true.
ST_Contains(A, B)
View ST_Contains Example
ST_Intersects
If two geometric objects intersect, return true.
ST_Intersects(A, B)
View ST_Intersects Example
ST_Disjoint
If two geometric objects do not intersect, return true.
ST_Disjoint(A, B)
View ST_Disjoint Example
ST_Within
Returns true if the given Geometry object A is completely inside object B.
ST_Within(A, B)