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.

8.1. PostgreSQL PostGIS Geometry/Geography/Box Types

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.

box2d — A box composed of x min, ymin, xmax, ymax. Often used to return the 2d enclosing box of a geometry.

box3d — A box composed of x min, ymin, zmin, xmax, ymax, zmax. Often used to return the 3d extent of a geometry or collection of geometries.

8.3. Management Functions

AddGeometryColumn — Adds a geometry column to an existing table of
attributes. By default uses type modifier to define rather than constraints.
Pass in false for use_typmod to get old check constraint based behavior

Populate_Geometry_Columns — Ensures geometry columns are defined with type modifiers or have appropriate spatial constraints
This ensures they will be registered correctly in 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

UpdateGeometrySRID — Updates the SRID of all features in a geometry
column, geometry_columns metadata and srid. If it was enforced with constraints, the constraints will be updated with new srid constraint.
If the old was enforced by type definition, the type definition will be changed.

8.4. Geometry Constructors

ST_BdPolyFromText — Construct a Polygon given an arbitrary collection of closed
linestrings as a MultiLineString Well-Known text representation.

ST_BdMPolyFromText — Construct a MultiPolygon given an arbitrary collection of
closed linestrings as a MultiLineString text
representation Well-Known text representation.

ST_PointN — Return the Nth point in the first LineString or circular LineString in the
geometry. Negative values are counted backwards from the end of the LineString. Returns NULL if there is no linestring in the
geometry.

ST_Points — Returns a MultiPoint containing all of the coordinates of a geometry.

ST_SRID — Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table.

ST_StartPoint — Returns the first point of a LINESTRING
geometry as a POINT.

ST_Area — Returns the area of the surface if it is a Polygon or
MultiPolygon. For geometry, a 2D Cartesian area is determined with units specified by the SRID. For geography, area is determined on a curved surface with units in square meters.

ST_Azimuth — Returns the north-based azimuth as the angle in radians measured clockwise from the vertical on pointA to pointB.

ST_ClosestPoint — Returns the 2-dimensional point on g1 that is closest to g2. This is the first point of
the shortest line.

ST_ClusterDBSCAN — Windowing function that returns integer id for the cluster each input geometry is in based on 2D implementation of Density-based spatial clustering of applications with noise (DBSCAN) algorithm.

ST_ClusterKMeans — Windowing function that returns integer id for the cluster each input geometry is in.

ST_ClusterWithin — Aggregate. Returns an array of GeometryCollections, where each GeometryCollection represents a set of geometries separated by no more than the specified distance.

ST_Contains — Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A.

ST_ContainsProperly — Returns true if B intersects the interior of A but not the boundary (or exterior). A does not contain properly itself, but does contain itself.

ST_Covers — Returns 1 (TRUE) if no point in Geometry B is outside
Geometry A

ST_CoveredBy — Returns 1 (TRUE) if no point in Geometry/Geography A is outside
Geometry/Geography B

ST_Crosses — Returns TRUE if the supplied geometries have some, but not all,
interior points in common.

ST_LineCrossingDirection — Given 2 linestrings, returns a number between -3 and 3 denoting what kind of crossing behavior. 0 is no crossing.

ST_Disjoint — Returns TRUE if the Geometries do not "spatially
intersect" - if they do not share any space together.

ST_Distance — For geometry type Returns the 2D Cartesian distance between two geometries in
projected units (based on spatial ref). For geography type defaults to return minimum geodesic distance between two geographies in meters.

ST_MinimumClearance — Returns the minimum clearance of a geometry, a measure of a geometry's robustness.

ST_HausdorffDistance — Returns the Hausdorff distance between two geometries. Basically a measure of how similar or dissimilar 2 geometries are. Units are in the units of the spatial
reference system of the geometries.

ST_FrechetDistance — Returns the Fréchet distance between two geometries. This is a measure of similarity between curves that takes into account the location
and ordering of the points along the curves. Units are in the units of the spatial reference system of the geometries.

ST_MaxDistance — Returns the 2-dimensional largest distance between two geometries in
projected units.

ST_DistanceSphere — Returns minimum distance in meters between two lon/lat
geometries. Uses a spherical earth and radius derived from the spheroid
defined by the SRID.
Faster than ST_DistanceSpheroid ST_DistanceSpheroid, but less
accurate. PostGIS versions prior to 1.5 only implemented for points.

ST_DistanceSpheroid — Returns the minimum distance between two lon/lat geometries given a
particular spheroid.
PostGIS versions prior to 1.5 only support points.

ST_DFullyWithin — Returns true if all of the geometries are within the specified
distance of one another

ST_DWithin — Returns true if the geometries are within the specified
distance of one another. For geometry units are in those of spatial reference and For geography units are in meters and measurement is
defaulted to use_spheroid=true (measure around spheroid), for faster check, use_spheroid=false to measure along sphere.

ST_Equals — Returns true if the given geometries represent the same geometry. Directionality
is ignored.

ST_Intersects — Returns TRUE if the Geometries/Geography "spatially
intersect in 2D" - (share any portion of space) and FALSE if they don't (they are Disjoint).
For geography -- tolerance is 0.00001 meters (so any points that close are considered to intersect)

ST_Length — Returns the 2D length of the geometry if it is a LineString or MultiLineString. geometry are in units of spatial reference and geography are in meters (default spheroid)

ST_Length2D — Returns the 2-dimensional length of the geometry if it is a
linestring or multi-linestring. This is an alias for ST_Length

ST_3DLength — Returns the 3-dimensional or 2-dimensional length of the geometry if it is a
linestring or multi-linestring.

ST_LengthSpheroid — Calculates the 2D or 3D length/perimeter of a geometry on an ellipsoid. This
is useful if the coordinates of the geometry are in
longitude/latitude and a length is desired without reprojection.

ST_Length2D_Spheroid — Calculates the 2D length/perimeter of a geometry on an ellipsoid. This
is useful if the coordinates of the geometry are in
longitude/latitude and a length is desired without reprojection.

ST_LongestLine — Returns the 2-dimensional longest line points of two geometries.
The function will only return the first longest line if more than one, that the function finds.
The line returned will always start in g1 and end in g2.
The length of the line this function returns will always be the same as st_maxdistance returns for g1 and g2.

ST_OrderingEquals — Returns true if the given geometries represent the same geometry
and points are in the same directional order.

ST_Overlaps — Returns TRUE if the Geometries share space, are of the same dimension, but are not completely contained by each other.

ST_Perimeter — Return the length measurement of the boundary of an ST_Surface
or ST_MultiSurface geometry or geography. (Polygon, MultiPolygon). geometry measurement is in units of spatial reference and geography is in meters.

ST_Perimeter2D — Returns the 2-dimensional perimeter of the geometry, if it
is a polygon or multi-polygon. This is currently an alias for ST_Perimeter.

ST_3DPerimeter — Returns the 3-dimensional perimeter of the geometry, if it
is a polygon or multi-polygon.

ST_Project — Returns a POINT projected from a start point using a distance in meters and bearing (azimuth) in radians.

ST_Relate — Returns true if this Geometry is spatially related to
anotherGeometry, by testing for intersections between the
Interior, Boundary and Exterior of the two geometries as specified
by the values in the intersectionMatrixPattern. If no intersectionMatrixPattern
is passed in, then returns the maximum intersectionMatrixPattern that relates the 2 geometries.

ST_Simplify — Returns a "simplified" version of the given geometry using
the Douglas-Peucker algorithm.

ST_SimplifyPreserveTopology — Returns a "simplified" version of the given geometry using
the Douglas-Peucker algorithm. Will avoid creating derived
geometries (polygons in particular) that are invalid.

ST_SimplifyVW — Returns a "simplified" version of the given geometry using the Visvalingam-Whyatt algorithm

ST_SetEffectiveArea —
Sets the effective area for each vertex, storing the value in the M ordinate. A simplified geometry can then be generated by filtering on the M ordinate.

ST_Split — Returns a collection of geometries resulting by splitting a geometry.

ST_SymDifference — Returns a geometry that represents the portions of A and B
that do not intersect. It is called a symmetric difference because
ST_SymDifference(A,B) = ST_SymDifference(B,A).

ST_Subdivide — Returns a set of geometry where no geometry in the set has more than the specified number of vertices.

ST_SwapOrdinates — Returns a version of the given geometry with
given ordinate values swapped.

ST_Union — Returns a geometry that represents the point set union of
the Geometries.

ST_UnaryUnion — Like ST_Union, but working at the geometry component level.

ST_VoronoiLines — Returns the boundaries between the cells of the Voronoi diagram constructed from the vertices of a geometry.

ST_VoronoiPolygons — Returns the cells of the Voronoi diagram constructed from the vertices of a geometry.

8.12. Linear Referencing

ST_LineInterpolatePoint — Returns a point interpolated along a line. Second argument is a float8 between 0 and 1
representing fraction of total length of linestring the point has to be located.

ST_LineLocatePoint — Returns a float between 0 and 1 representing the location of
the closest point on LineString to the given Point, as a fraction
of total 2d line length.

ST_LineSubstring — Return a linestring being a substring of the input one
starting and ending at the given fractions of total 2d length.
Second and third arguments are float8 values between 0 and
1.

ST_LocateAlong — Return a derived geometry collection value with elements
that match the specified measure. Polygonal elements are not
supported.

ST_LocateBetween — Return a derived geometry collection value with elements
that match the specified range of measures inclusively. Polygonal
elements are not supported.

ST_LocateBetweenElevations — Return a derived geometry (collection) value with elements
that intersect the specified range of elevations inclusively. Only 3D, 4D LINESTRINGS and MULTILINESTRINGS
are supported.

ST_InterpolatePoint — Return the value of the measure dimension of a geometry at the point closed to the provided point.

ST_AddMeasure — Return a derived geometry with measure elements linearly interpolated between the start and end points.

8.13. Temporal Support

ST_DistanceCPA —
Returns the distance between closest points of approach in two trajectories.

ST_CPAWithin —
Returns true if the trajectories' closest points of approach
are within the specified distance.

8.14. Long Transactions Support

AddAuth — Add an authorization token to be used in current transaction.

CheckAuth — Creates trigger on a table to prevent/allow updates and deletes of rows based on authorization token.

DisableLongTransactions — Disable long transaction support. This function removes the
long transaction support metadata tables, and drops all triggers
attached to lock-checked tables.

EnableLongTransactions — Enable long transaction support. This function creates the
required metadata tables, needs to be called once before using the
other functions in this section. Calling it twice is
harmless.

8.16. Exceptional Functions

PostGIS_HasBBox — Returns TRUE if the bbox of this geometry is cached, FALSE otherwise.

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.