Overview
Geospatial functions allow you to describe geometric objects in well-known text (WKT) format.
Type | WKT format |
---|---|
Point | POINT (0 0) |
LineString | LINESTRING (0 0, 1 1, 1 2) |
Polygon | POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)) |
MultiPoint | MULTIPOINT (0 0, 1 2) |
MultiLineString | MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4)) |
MultiPolygon | MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1
-2, -2 -2, -2 -1, -1 -1))) |
GeometryCollection | GEOMETRYCOLLECTION (POINT(2 3), LINESTRING (2 3, 3 4)) |
Constructors
Function | Description |
---|---|
ST_Point(double, double) → Point | Returns a geometry type point based on the specified coordinate values. |
ST_LineFromText(varchar) → LineString | Returns a geometry type linestring object from a WKT representation. |
ST_Polygon(varchar) → Polygon | Returns a geometry type polygon object from a WKT representation. |
ST_GeometryFromText(varchar) → Geometry | Returns a geometry type object from a WKT representation. |
ST_AsText(Geometry) → varchar | Returns the WKT representation of geometric object. |
Operations
Function | Description |
---|---|
ST_Boundary(Geometry) → Geometry | Returns the closure of the combinatorial boundary of the geometric object. |
ST_Buffer(Geometry, distance) → Geometry | Returns the geometric object that represents all points whose distance from the specified geometric object is less than or equal to the specified distance. |
ST_Difference(Geometry, Geometry) → Geometry | Returns the geometry value that represents the point set difference of the specified geometric objects. |
ST_Envelope(Geometry) → Geometry | Returns the bounding rectangular polygon of a geometric object. |
ST_ExteriorRing(Geometry) → Geometry | Returns a line string representing the exterior ring of the input polygon. |
ST_Intersection(Geometry, Geometry) → Geometry | Returns the geometry value that represents the point set intersection of two geometric objects. |
ST_SymDifference(Geometry, Geometry) → Geometry | Returns the geometry value that represents the point set symmetric difference of two geometric objects. |
Relationship tests
Function | Description |
---|---|
ST_Contains(Geometry, Geometry) → boolean | Returns true if and only if no points of the second geometric object lie in the exterior of the first geometric object, and at least one point of the interior of the first geometric object lies in the interior of the second geometric object. Returns false if points of the second geometric object are on the boundary of the first geometric object. |
ST_Crosses(Geometry, Geometry) → boolean | Returns true if the supplied geometric objects have some, but not all, interior points in common. |
ST_Disjoint(Geometry, Geometry) → boolean | Returns true if the specified geometric objects do not spatially intersect. |
ST_Equals(Geometry, Geometry) → boolean | Returns true if the specified geometric objects represent the same geometric object. |
ST_Intersects(Geometry, Geometry) → boolean | Returns true if the specified geometric objects spatially intersect in two dimensions. |
ST_Overlaps(Geometry, Geometry) → boolean | Returns true if the specified geometric objects share space, are of the same dimension, but are not completely contained by each other. |
ST_Relate(Geometry, Geometry) → boolean | Returns true if the first geometric object is spatially related to the second geometric object. |
ST_Touches(Geometry, Geometry) → boolean | Returns true if the specified geometric objects have at least one point in common, but their interiors do not intersect. |
ST_Within(Geometry, Geometry) → boolean | Returns true if the first geometric object is completely inside the second geometric object. Returns false if the two geometric objects have points in common at the boundaries. |
Accessors
Function | Description |
---|---|
ST_Area(Geometry) → double | Returns the two-dimensional Euclidean area of a geometric object. |
ST_Centroid(Geometry) → Geometry | Returns the point value that is the mathematical centroid of a geometric object. |
ST_CoordDim(Geometry) → bigint | Returns the coordinate dimension of a geometric object. |
ST_Dimension(Geometry) → bigint | Returns the inherent dimension of a geometric object, which must be less than or equal to the coordinate dimension. |
ST_Distance(Geometry, Geometry) → double | Returns the minimum two-dimensional Cartesian distance (based on spatial ref) between two geometric objects in projected units. |
ST_IsClosed(Geometry) → boolean | Returns true if the start and end points of the linestring are coincident. |
ST_IsEmpty(Geometry) → boolean | Returns true if Geometry is an empty geometric object such as geometry collection, polygon, and point. |
ST_IsRing(Geometry) → boolean | Returns true if and only if the line is closed and simple. |
ST_Length(Geometry) → double | Returns the length of a linestring or multi-linestring by using Euclidean measurement on a two-dimensional plane (based on spatial ref) in projected units. |
ST_XMax(Geometry) → double | Returns X maxima of a bounding box of a geometric object. |
ST_YMax(Geometry) → double | Returns Y maxima of a bounding box of a geometric object. |
T_XMin(Geometry) → double | Returns X minima of a bounding box of a geometric object. |
ST_YMin(Geometry) → double | Returns Y minima of a bounding box of a geometric object. |
ST_StartPoint(Geometry) → point | Returns the first point of a linestring geometric object. |
ST_EndPoint(Geometry) → point | Returns the last point of a linestring geometric object. |
ST_X(Point) → double | Returns the X coordinate of the point. |
ST_Y(Point) → double | Returns the Y coordinate of the point. |
ST_NumPoints(Geometry) → bigint | Returns the number of points in a geometric object. |
ST_NumInteriorRing(Geometry) → bigint | Returns the cardinality of the collection of interior rings of a polygon. |