Skip to content

Geometry Functions

This section describes the functions for examining and manipulating GEOMETRY values.

The spatial extension provides additional functions for working with GEOMETRY values, which are documented in the Spatial Functions section.

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

| Description | Creates a geometry from Well-Known Binary (WKB) representation | | Example | ST_GeomFromWKB('\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF0?\x00\x00\x00\x00\x00\x00\x00@') | | Result | POINT(1 2) |

ST_AsWKB function

| Description | Returns the Well-Known Binary (WKB) representation of the geometry | | Example | ST_AsWKB('POINT(1 2)::GEOMETRY') | | Result | \x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\xF0?\x00\x00\x00\x00\x00\x00\x00@ | | Alias | ST_AsBinary |

ST_AsWKT function

| Description | Returns the Well-Known Text (WKT) representation of the geometry | | Example | ST_AsText('POINT(1 2)'::GEOMETRY) | | Result | POINT (1 2) | | Alias | ST_AsText |

ST_Intersects_Extent function

| Description | Returns true if the geometries bounding boxes intersect | | Example | 'POINT(5 5)'::GEOMETRY && 'LINESTRING(0 0, 10 20)'::GEOMETRY | | Result | true | | Alias | && |

ST_CRS function

| Description | Returns the Coordinate Reference System (CRS) identifier of the geometry | | Example | ST_CRS('POINT(1 2)'::GEOMETRY('OGC:CRS84')) | | Result | OGC:CRS84 |

ST_SetCRS function

| Description | Sets the Coordinate Reference System (CRS) identifier of the geometry | | Example | typeof(ST_SetCRS('POINT(1 2)'::GEOMETRY, 'OGC:CRS84')) | | Result | GEOMETRY('OGC:CRS84') |