Table of Contents
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. |
Abstract
This section lists the PostgreSQL data types installed by PostGIS. Note we describe the casting behavior of these which is very important especially when designing your own functions.
A Cast is when one type is coerced into another type. PostgreSQL is unique from most databases in that it allows you to define casting behavior for custom types and the functions used for casting. A cast can be specified as automatic in which case, you do not have to do a CAST(myfoo As otherfootype) or myfoo::otherfootype if you are feeding it to a function that only works with otherfootype and there is an automatic cast in place for it.
The danger of relying on automatic cast behavior is when you have an overloaded function say one that takes a box2d and one that takes a box3d but no geometry. What happens is that both functions are equally good to use with geometry since geometry has an autocast for both -- so you end up with an ambiguous function error. To force PostgreSQL to choose, you do a CAST(mygeom As box3d) or mygeom::box3d.
At least as of PostgreSQL 8.3 - Everything can be CAST to text (presumably because of the magical unknown type), so no defined CASTS for that need to be present for you to CAST an object to text.
geometry_columns
view. By default will convert all geometry
columns with no type modifier to ones with type modifiers. To get old behavior set use_typmod=false
LINESTRING
from WKB with the given SRIDLINESTRING
geometry as a POINT
.POLYGON
geometry. Return
NULL if the geometry is not a polygon. Will not work with MULTIPOLYGONTRUE
if the
LINESTRING
's start and end points are coincident. For Polyhedral surface is closed (volumetric).
TRUE
if the argument is a
collection (MULTI*
, GEOMETRYCOLLECTION
, ...)
TRUE
if this
LINESTRING
is both closed and simple.true
if the
ST_Geometry
is well formed.
LINESTRING
geometry as a POINT
.TRUE
if A's 2D bounding box intersects B's 2D bounding box.TRUE
if A's n-D bounding box intersects B's n-D bounding box.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 A's bounding box is the same as B's. Uses double precision bounding box.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'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's bounding box is the same as B's.TRUE
if the supplied geometries have some, but not all,
interior points in common.ST_Length
POINT
guaranteed to lie on the surface.POINT
projected from a start point using a distance in meters and bearing (azimuth) in radians.TRUE
if the geometries have at least one point in common,
but their interiors do not intersect.Abstract
SFCGAL is a C++ wrapper library around CGAL that provides advanced 2D and 3D functions. For robustness, geometry coordinates have an exact rational number representation.
Installation instructions of the library can be found on SFCGAL home page http://www.sfcgal.org. To load the functions execute postgis/sfcgal.sql
Some SFCGAL functions replace standard ones (ST_Intersects, ST_Intersection, ST_Difference, ST_Union, ST_Area and ST_Distance), to switch between standard functions and SFCGAL function use:
SET postgis.backend = sfcgal;
and
SET postgis.backend = geos;
geometry_dump
rows, representing
the exterior and interior rings of a polygon.This module and associated pl/pgsql functions have been implemented to provide long locking support required by Web Feature Service specification.
Users must use serializable transaction level otherwise locking mechanism would break. |
These functions are rarely used functions that should only be used if your data is corrupted in someway. They are used for troubleshooting corruption and also fixing things that should under normal circumstances, never happen.