Geometry Functions
This section describes the built-in functions for examining and manipulating GEOMETRY values.
Geometry Operators
The table below lists the operators that can be used with GEOMETRY values.
| Operator | Description | Example | Result |
|---|---|---|---|
&& | Returns true if the geometries bounding boxes intersect. Equivalent to ST_IntersectsExtent. | 'POINT(5 5)'::GEOMETRY && 'LINESTRING(0 0, 10 20)'::GEOMETRY | true |
Built-in Geometry Functions
| Name | Description |
|---|---|
ST_GeomFromWKB | Creates a geometry from Well-Known Binary (WKB) representation |
ST_AsWKB | Returns the Well-Known Binary (WKB) representation of the geometry |
ST_AsWKT | Returns the Well-Known Text (WKT) representation of the geometry |
ST_Intersects_Extent | Returns true if the geometries bounding boxes intersect |
ST_CRS | Returns the Coordinate Reference System (CRS) identifier of the geometry |
ST_SetCRS | Sets the Coordinate Reference System (CRS) identifier of the geometry |
ST_GeomFromWKB function
Creates a geometry from Well-Known Binary (WKB) representation.
Query
SELECT ST_AsText(ST_GeomFromWKB('\x0101000000000000000000f03f0000000000000040'::BLOB)) AS geom;Result
geom------------- POINT (1 2)ST_AsWKB function
Returns the Well-Known Binary (WKB) representation of the geometry. Alias: ST_AsBinary.
Query
SELECT ST_AsWKB('POINT(1 2)'::GEOMETRY) AS wkb;Result
wkb----------------------------------------------- \\x0101000000000000000000f03f0000000000000040ST_AsWKT function
Returns the Well-Known Text (WKT) representation of the geometry. Alias: ST_AsText.
Query
SELECT ST_AsText('POINT(1 2)'::GEOMETRY) AS wkt;Result
wkt------------- POINT (1 2)ST_Intersects_Extent function
Returns true if the geometries bounding boxes intersect. Alias: &&.
Query
SELECT ST_Intersects_Extent('POINT(5 5)'::GEOMETRY, 'LINESTRING(0 0, 10 20)'::GEOMETRY) AS intersects;Result
intersects------------ tST_CRS function
Returns the Coordinate Reference System (CRS) identifier of the geometry.
Query
SELECT ST_CRS('POINT(1 2)'::GEOMETRY('OGC:CRS84')) AS crs;Result
crs----------- OGC:CRS84ST_SetCRS function
Sets the Coordinate Reference System (CRS) identifier of the geometry.
Query
SELECT typeof(ST_SetCRS('POINT(1 2)'::GEOMETRY, 'OGC:CRS84')) AS type;Result
type----------------------- GEOMETRY('OGC:CRS84')