The functions given below are the ones which a user of PostGIS is likely to need. There are other functions which are required support functions to the PostGIS objects which are not of use to a general user.
PostGIS has begun a transition from the existing naming convention to an SQL-MM-centric convention. As a result, most of the functions that you know and love have been renamed using the standard spatial type (ST) prefix. Previous functions are still available, though are not listed in this document where updated functions are equivalent. The non ST_ functions not listed in this documentation are deprecated and will be removed in a future release so STOP USING THEM. |
This section lists the custom PostgreSQL data types installed by PostGIS to represent spatial data.
Each data type describes its type casting behavior. A type cast converts values of one data type into another type. PostgreSQL allows defining casting behavior for custom types, along with the functions used to convert type values. Casts can have automatic behavior, which allows automatic conversion of a function argument to a type supported by the function.
Some casts have explicit behavior,
which means the cast must be specified using the syntax CAST(myval As sometype)
or myval::sometype
.
Explicit casting avoids the issue of ambiguous casts,
which can occur when using an overloaded function which does not support a given type.
For example, a function may accept a box2d or a box3d, but not a geometry.
Since geometry has an automatic cast to both box types, this produces an "ambiguous function" error.
To prevent the error use an explicit cast to the desired box type.
All data types can be cast to text
, so this does not need to be specified explicitly.
These functions assist in defining tables containing geometry columns.
geometry_dump
rows for the components of a geometry.
geometry_dump
rows for the coordinates in a geometry.
geometry_dump
rows for the segments in a geometry.
geometry_dump
rows for
the exterior and interior rings of a Polygon.
These functions create modified geometries by changing type, structure or vertices.
These functions test whether geometries are valid according to the OGC SFS standard. They also provide information about the nature and location of invalidity. There is also a function to create a valid geometry out of an invalid one.
valid_detail
row stating if a geometry is valid or if not a reason and a location.
These functions work with the Spatial Reference System of geometries
as defined in the spatial_ref_sys
table.
These functions create geometry objects from various textual or binary formats.
LINESTRING
from WKB with the given SRID
These functions convert geometry objects into various textual or binary formats.
TRUE
if A's 2D bounding box intersects B's 2D bounding box.
TRUE
if a geometry's (cached) 2D bounding box intersects a 2D float precision bounding box (BOX2DF).
TRUE
if a 2D float precision bounding box (BOX2DF) intersects a geometry's (cached) 2D bounding box.
TRUE
if two 2D float precision bounding boxes (BOX2DF) intersect each other.
TRUE
if A's n-D bounding box intersects B's n-D bounding box.
TRUE
if a geometry's (cached) n-D bounding box intersects a n-D float precision bounding box (GIDX).
TRUE
if a n-D float precision bounding box (GIDX) intersects a geometry's (cached) n-D bounding box.
TRUE
if two n-D float precision bounding boxes (GIDX) intersect each other.
TRUE
if A's bounding box overlaps or is to the left of B's.
TRUE
if A's bounding box overlaps or is below B's.
TRUE
if A' bounding box overlaps or is to the right of B's.
TRUE
if A's bounding box is strictly to the left of B's.
TRUE
if A's bounding box is strictly below B's.
TRUE
if the coordinates and coordinate order geometry/geography A
are the same as the coordinates and coordinate order of geometry/geography B.
TRUE
if A's bounding box is strictly to the right of B's.
TRUE
if A's bounding box is contained by B's.
TRUE
if a geometry's 2D bounding box is contained into a 2D float precision bounding box (BOX2DF).
TRUE
if a 2D float precision bounding box (BOX2DF) is contained into a geometry's 2D bounding box.
TRUE
if a 2D float precision bounding box (BOX2DF) is contained into another 2D float precision bounding box.
TRUE
if A's bounding box overlaps or is above B's.
TRUE
if A's bounding box is strictly above B's.
TRUE
if A's bounding box contains B's.
TRUE
if a geometry's 2D bonding box contains a 2D float precision bounding box (GIDX).
TRUE
if a 2D float precision bounding box (BOX2DF) contains a geometry's 2D bonding box.
TRUE
if a 2D float precision bounding box (BOX2DF) contains another 2D float precision bounding box (BOX2DF).
TRUE
if A's bounding box is the same as B's.
These functions determine spatial relationships between geometries.
These functions compute measurements of distance, area and angles. There are also functions to compute geometry values determined by measurements.
ST_Length
ST_Perimeter
.
These functions compute results arising from the overlay of two geometries. These are also known as point-set theoretic boolean operations. Some related functions are also provided.
These functions compute geometric constructions, or alter geometry size or shape.
These functions operate on sets of polygonal geometry that form "implicit coverages". To form a valid coverage polygons must not overlap, and the vertices of adjacent edges must match exactly. Coverages are fast to process, and can be operated on with window functions, which retain the coverage topology inside the window partition while altering the edges.
These functions change the position and shape of geometries using affine transformations.
These functions implement clustering algorithms for sets of geometries.
These functions produce or operate on bounding boxes. They can also provide and accept geometry values, by using automatic or explicit casts.
See also Section 13.7, “PostGIS Box Functions”.
These functions support working with trajectories. A trajectory is a linear geometry with increasing measures (M value) on each coordinate. Spatio-temporal data can be modeled by using relative times (such as the epoch) as the measure values.
These functions report and upgrade PostGIS versions.
This section lists custom PostGIS Grand Unified Custom Variables (GUC). These can be set globally, by database, by session or by transaction. Best set at global or database level.
These functions are utilities for troubleshooting and repairing geometry data. They are only needed if the geometry data is corrupted in some way, which should never happen under normal circumstances.