Chapter 8. PostGIS Special Functions Index
8.1. PostGIS Aggregate Functions
The functions given below are spatial aggregate functions provided with PostGIS that can be used just like any other sql aggregate function such as sum, average.
- ST_Accum - Aggregate. Constructs an array of geometries.
- ST_Collect - Return a specified ST_Geometry value from a collection of other geometries.
- ST_Extent - an aggregate function that returns the bounding box that bounds rows of geometries.
- ST_Extent3D - an aggregate function that returns the box3D bounding box that bounds rows of geometries.
- ST_MakeLine - Creates a Linestring from point geometries.
- ST_MemUnion - Same as ST_Union, only memory-friendly (uses less memory and more processor time).
- ST_Polygonize - Aggregate. Creates a GeometryCollection containing possible polygons formed from the constituent linework of a set of geometries.
- ST_Union - Returns a geometry that represents the point set union of the Geometries.
8.2. PostGIS SQL-MM Compliant Functions
The functions given below are PostGIS functions that conform to the SQL/MM 3 standard
| |
---|
SQL-MM defines the default SRID of all geometry constructors as 0.
PostGIS uses a default SRID of -1. |
- ST_Area - Returns the area of the surface if it is a polygon or multi-polygon. For "geometry" type area is in SRID units. For "geography" area is in square meters.
This method implements the SQL/MM specification. SQL-MM 3: 8.1.2, 9.5.3
- ST_AsBinary - Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.37
- ST_AsText - Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.25
- ST_Boundary - Returns the closure of the combinatorial boundary of this Geometry.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.14
- ST_Buffer - (T) For geometry: Returns a geometry that represents all points whose distance from this Geometry is less than or equal to distance. Calculations are in the Spatial Reference System of this Geometry. For geography: Uses a planar transform wrapper. Introduced in 1.5 support for different end cap and mitre settings to control shape. buffer_style options: quad_segs=#,endcap=round|flat|square,join=round|mitre|bevel,mitre_limit=#.#
This method implements the SQL/MM specification. SQL-MM 3: 5.1.17
- ST_Centroid - Returns the geometric center of a geometry.
This method implements the SQL/MM specification. SQL-MM 3: 8.1.4, 9.5.5
- 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.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.31
- ST_ConvexHull - The convex hull of a geometry represents the minimum convex geometry that encloses all geometries within the set.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.16
- ST_CoordDim - Return the coordinate dimension of the ST_Geometry value.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.3
- ST_Crosses - Returns TRUE if the supplied geometries have some, but not all, interior points in common.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.29
- ST_CurveToLine - Converts a CIRCULARSTRING/CURVEDPOLYGON to a LINESTRING/POLYGON
This method implements the SQL/MM specification. SQL-MM 3: 7.1.7
- ST_Difference - Returns a geometry that represents that part of geometry A that does not intersect with geometry B.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.20
- ST_Dimension - The inherent dimension of this Geometry object, which must be less than or equal to the coordinate dimension.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.2
- ST_Disjoint - Returns TRUE if the Geometries do not "spatially intersect" - if they do not share any space together.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.26
- ST_Distance - For geometry type Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units. For geography type defaults to return spheroidal minimum distance between two geographies in meters.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.23
- ST_EndPoint - Returns the last point of a LINESTRING geometry as a POINT.
This method implements the SQL/MM specification. SQL-MM 3: 7.1.4
- ST_Envelope - Returns a geometry representing the double precision (float8) bounding box of the supplied geometry.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.15
- ST_Equals - Returns true if the given geometries represent the same geometry. Directionality is ignored.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.24
- ST_ExteriorRing - Returns a line string representing the exterior ring of the POLYGON geometry. Return NULL if the geometry is not a polygon. Will not work with MULTIPOLYGON
This method implements the SQL/MM specification. SQL-MM 3: 8.2.3, 8.3.3
- ST_GMLToSQL - Return a specified ST_Geometry value from GML representation. This is an alias name for ST_GeomFromGML
This method implements the SQL/MM specification. SQL-MM 3: 5.1.50 (except for curves support).
- ST_GeomCollFromText - Makes a collection Geometry from collection WKT with the given SRID. If SRID is not give, it defaults to -1.
This method implements the SQL/MM specification.
- ST_GeomFromText - Return a specified ST_Geometry value from Well-Known Text representation (WKT).
This method implements the SQL/MM specification. SQL-MM 3: 5.1.40
- ST_GeomFromWKB - Creates a geometry instance from a Well-Known Binary geometry representation (WKB) and optional SRID.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.41
- ST_GeometryFromText - Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an alias name for ST_GeomFromText
This method implements the SQL/MM specification. SQL-MM 3: 5.1.40
- ST_GeometryN - Return the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or MULTIPOLYGON. Otherwise, return NULL.
This method implements the SQL/MM specification. SQL-MM 3: 9.1.5
- ST_GeometryType - Return the geometry type of the ST_Geometry value.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.4
- ST_InteriorRingN - Return the Nth interior linestring ring of the polygon geometry. Return NULL if the geometry is not a polygon or the given N is out of range.
This method implements the SQL/MM specification. SQL-MM 3: 8.2.6, 8.3.5
- ST_Intersection - (T) Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation does a transform to geometry to do the intersection and then transform back to WGS84.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.18
- ST_Intersects - Returns TRUE if the Geometries/Geography "spatially intersect" - (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)
This method implements the SQL/MM specification. SQL-MM 3: 5.1.27
- ST_IsClosed - Returns TRUE if the LINESTRING's start and end points are coincident.
This method implements the SQL/MM specification. SQL-MM 3: 7.1.5, 9.3.3
- ST_IsEmpty - Returns true if this Geometry is an empty geometry . If true, then this Geometry represents the empty point set - i.e. GEOMETRYCOLLECTION(EMPTY).
This method implements the SQL/MM specification. SQL-MM 3: 5.1.7
- ST_IsRing - Returns TRUE if this LINESTRING is both closed and simple.
This method implements the SQL/MM specification. SQL-MM 3: 7.1.6
- ST_IsSimple - Returns (TRUE) if this Geometry has no anomalous geometric points, such as self intersection or self tangency.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.8
- ST_IsValid - Returns true if the ST_Geometry is well formed.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.9
- 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)
This method implements the SQL/MM specification. SQL-MM 3: 7.1.2, 9.3.4
- ST_LineFromText - Makes a Geometry from WKT representation with the given SRID. If SRID is not given, it defaults to -1.
This method implements the SQL/MM specification. SQL-MM 3: 7.2.8
- ST_LineFromWKB - Makes a LINESTRING from WKB with the given SRID
This method implements the SQL/MM specification. SQL-MM 3: 7.2.9
- ST_LinestringFromWKB - Makes a geometry from WKB with the given SRID.
This method implements the SQL/MM specification. SQL-MM 3: 7.2.9
- ST_M - Return the M coordinate of the point, or NULL if not available. Input must be a point.
This method implements the SQL/MM specification.
- ST_MLineFromText - Return a specified ST_MultiLineString value from WKT representation.
This method implements the SQL/MM specification.SQL-MM 3: 9.4.4
- ST_MPointFromText - Makes a Geometry from WKT with the given SRID. If SRID is not give, it defaults to -1.
This method implements the SQL/MM specification. SQL-MM 3: 9.2.4
- ST_MPolyFromText - Makes a MultiPolygon Geometry from WKT with the given SRID. If SRID is not give, it defaults to -1.
This method implements the SQL/MM specification. SQL-MM 3: 9.6.4
- ST_NumGeometries - If geometry is a GEOMETRYCOLLECTION (or MULTI*) return the number of geometries, otherwise return NULL.
This method implements the SQL/MM specification. SQL-MM 3: 9.1.4
- ST_NumInteriorRing - Return the number of interior rings of the first polygon in the geometry. Synonym to ST_NumInteriorRings.
This method implements the SQL/MM specification. SQL-MM 3: 8.2.5
- ST_NumInteriorRings - Return the number of interior rings of the first polygon in the geometry. This will work with both POLYGON and MULTIPOLYGON types but only looks at the first polygon. Return NULL if there is no polygon in the geometry.
This method implements the SQL/MM specification. SQL-MM 3: 8.2.5
- ST_NumPoints - Return the number of points in an ST_LineString or ST_CircularString value.
This method implements the SQL/MM specification. SQL-MM 3: 7.2.4
- ST_OrderingEquals - Returns true if the given geometries represent the same geometry and points are in the same directional order.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.43
- ST_Overlaps - Returns TRUE if the Geometries share space, are of the same dimension, but are not completely contained by each other.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.32
- ST_Perimeter - Return the length measurement of the boundary of an ST_Surface or ST_MultiSurface value. (Polygon, Multipolygon)
This method implements the SQL/MM specification. SQL-MM 3: 8.1.3, 9.5.4
- ST_Point - Returns an ST_Point with the given coordinate values. OGC alias for ST_MakePoint.
This method implements the SQL/MM specification. SQL-MM 3: 6.1.2
- ST_PointFromText - Makes a point Geometry from WKT with the given SRID. If SRID is not given, it defaults to unknown.
This method implements the SQL/MM specification. SQL-MM 3: 6.1.8
- ST_PointFromWKB - Makes a geometry from WKB with the given SRID
This method implements the SQL/MM specification. SQL-MM 3: 6.1.9
- ST_PointN - Return the Nth point in the first linestring or circular linestring in the geometry. Return NULL if there is no linestring in the geometry.
This method implements the SQL/MM specification. SQL-MM 3: 7.2.5, 7.3.5
- ST_PointOnSurface - Returns a POINT guaranteed to lie on the surface.
This method implements the SQL/MM specification. SQL-MM 3: 8.1.5, 9.5.6.
According to the specs, ST_PointOnSurface works for surface geometries (POLYGONs, MULTIPOLYGONS, CURVED POLYGONS). So PostGIS seems to be extending what
the spec allows here. Most databases Oracle,DB II, ESRI SDE seem to only support this function for surfaces. SQL Server 2008 like PostGIS supports for all common geometries.
- ST_Polygon - Returns a polygon built from the specified linestring and SRID.
This method implements the SQL/MM specification. SQL-MM 3: 8.3.2
- ST_PolygonFromText - Makes a Geometry from WKT with the given SRID. If SRID is not give, it defaults to -1.
This method implements the SQL/MM specification. SQL-MM 3: 8.3.6
- 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.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.25
- ST_SRID - Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.5
- ST_StartPoint - Returns the first point of a LINESTRING geometry as a POINT.
This method implements the SQL/MM specification. SQL-MM 3: 7.1.3
- 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).
This method implements the SQL/MM specification. SQL-MM 3: 5.1.21
- ST_Touches - Returns TRUE if the geometries have at least one point in common, but their interiors do not intersect.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.28
- ST_Transform - Returns a new geometry with its coordinates transformed to the SRID referenced by the integer parameter.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.6
- ST_Union - Returns a geometry that represents the point set union of the Geometries.
This method implements the SQL/MM specification. SQL-MM 3: 5.1.19
the z-index (elevation) when polygons are involved.
- ST_WKBToSQL - Return a specified ST_Geometry value from Well-Known Binary representation (WKB). This is an alias name for ST_GeomFromWKB that takes no srid
This method implements the SQL/MM specification. SQL-MM 3: 5.1.36
- ST_WKTToSQL - Return a specified ST_Geometry value from Well-Known Text representation (WKT). This is an alias name for ST_GeomFromText
This method implements the SQL/MM specification. SQL-MM 3: 5.1.34
- ST_Within - Returns true if the geometry A is completely inside geometry B
This method implements the SQL/MM specification. SQL-MM 3: 5.1.30
- ST_X - Return the X coordinate of the point, or NULL if not available. Input must be a point.
This method implements the SQL/MM specification. SQL-MM 3: 6.1.3
- ST_Y - Return the Y coordinate of the point, or NULL if not available. Input must be a point.
This method implements the SQL/MM specification. SQL-MM 3: 6.1.4
- ST_Z - Return the Z coordinate of the point, or NULL if not available. Input must be a point.
This method implements the SQL/MM specification.
8.3. PostGIS Geography Support Functions
The functions and operators given below are PostGIS functions/operators that take as input or return as output a geography data type object.
| |
---|
Functions with a (T) are not native geodetic functions, and use a ST_Transform call to and from geometry to do the operation. As a result, they may not behave as expected when going over dateline, poles,
and for large geometries or geometry pairs that cover more than one UTM zone. Basic tranform - (favoring UTM, Lambert Azimuthal (North/South), and falling back on mercator in worst case scenario) |
- ST_Area - Returns the area of the surface if it is a polygon or multi-polygon. For "geometry" type area is in SRID units. For "geography" area is in square meters.
- ST_AsBinary - Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.
- ST_AsGML - Return the geometry as a GML version 2 or 3 element.
- ST_AsGeoJSON - Return the geometry as a GeoJSON element.
- ST_AsKML - Return the geometry as a KML element. Several variants. Default version=2, default precision=15
- ST_AsSVG - Returns a Geometry in SVG path data given a geometry or geography object.
- ST_AsText - Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.
- ST_Buffer - (T) For geometry: Returns a geometry that represents all points whose distance from this Geometry is less than or equal to distance. Calculations are in the Spatial Reference System of this Geometry. For geography: Uses a planar transform wrapper. Introduced in 1.5 support for different end cap and mitre settings to control shape. buffer_style options: quad_segs=#,endcap=round|flat|square,join=round|mitre|bevel,mitre_limit=#.#
- ST_CoveredBy - Returns 1 (TRUE) if no point in Geometry/Geography A is outside Geometry/Geography B
- ST_Covers - Returns 1 (TRUE) if no point in Geometry B is outside Geometry A. For geography: if geography point B is not outside Polygon Geography A
- 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_Distance - For geometry type Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units. For geography type defaults to return spheroidal minimum distance between two geographies in meters.
- ST_GeogFromText - Return a specified geography value from Well-Known Text representation or extended (WKT).
- ST_GeogFromWKB - Creates a geography instance from a Well-Known Binary geometry representation (WKB) or extended Well Known Binary (EWKB).
- ST_GeographyFromText - Return a specified geography value from Well-Known Text representation or extended (WKT).
- = - Returns TRUE if A's bounding box is the same as B's (uses float4 boxes).
- && - Returns TRUE if A's bounding box overlaps B's.
- ST_Intersection - (T) Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation does a transform to geometry to do the intersection and then transform back to WGS84.
- ST_Intersects - Returns TRUE if the Geometries/Geography "spatially intersect" - (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)
8.4. PostGIS Geometry Dump Functions
The functions given below are PostGIS functions that take as input or return as output a set of or single geometry_dump data type object.
- ST_Dump - Returns a set of geometry_dump (geom,path) rows, that make up a geometry g1.
- ST_DumpPoints - Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.
- ST_DumpRings - Returns a set of geometry_dump rows, representing the exterior and interior rings of a polygon.
8.5. PostGIS Box Functions
The functions given below are PostGIS functions that take as input or return as output the box* family of PostGIS spatial types.
The box family of types consists of box2d, box3d, box3d_extent
- Box2D - Returns a BOX2D representing the maximum extents of the geometry.
- Box3D - Returns a BOX3D representing the maximum extents of the geometry.
- ST_Estimated_Extent - Return the 'estimated' extent of the given spatial table. The estimated is taken from the geometry column's statistics. The current schema will be used if not specified.
- ST_Expand - Returns bounding box expanded in all directions from the bounding box of the input geometry. Uses double-precision
- ST_Extent - an aggregate function that returns the bounding box that bounds rows of geometries.
- ST_Extent3D - an aggregate function that returns the box3D bounding box that bounds rows of geometries.
- ST_MakeBox2D - Creates a BOX2D defined by the given point geometries.
- ST_MakeBox3D - Creates a BOX3D defined by the given 3d point geometries.
- ST_XMax - Returns X maxima of a bounding box 2d or 3d or a geometry.
- ST_XMin - Returns X minima of a bounding box 2d or 3d or a geometry.
- ST_YMax - Returns Y maxima of a bounding box 2d or 3d or a geometry.
- ST_YMin - Returns Y minima of a bounding box 2d or 3d or a geometry.
- ST_ZMax - Returns Z minima of a bounding box 2d or 3d or a geometry.
- ST_ZMin - Returns Z minima of a bounding box 2d or 3d or a geometry.
8.6. PostGIS Functions that support 3D
The functions given below are PostGIS functions that do not throw away the Z-Index.
- AddGeometryColumn - Adds a geometry column to an existing table of attributes.
- Box3D - Returns a BOX3D representing the maximum extents of the geometry.
- DropGeometryColumn - Removes a geometry column from a spatial table.
- ST_Accum - Aggregate. Constructs an array of geometries.
- ST_AddMeasure - Return a derived geometry with measure elements linearly interpolated between the start and end points. If the geometry has no measure dimension, one is added. If the geometry has a measure dimension, it is over-written with new values. Only LINESTRINGS and MULTILINESTRINGS are supported.
- ST_AddPoint - Adds a point to a LineString before point <position> (0-based index).
- ST_Affine - Applies a 3d affine transformation to the geometry to do things like translate, rotate, scale in one step.
- ST_AsEWKB - Return the Well-Known Binary (WKB) representation of the geometry with SRID meta data.
- ST_AsEWKT - Return the Well-Known Text (WKT) representation of the geometry with SRID meta data.
- ST_AsGML - Return the geometry as a GML version 2 or 3 element.
- ST_AsGeoJSON - Return the geometry as a GeoJSON element.
- ST_AsHEXEWKB - Returns a Geometry in HEXEWKB format (as text) using either little-endian (NDR) or big-endian (XDR) encoding.
- ST_AsKML - Return the geometry as a KML element. Several variants. Default version=2, default precision=15
- ST_Boundary - Returns the closure of the combinatorial boundary of this Geometry.
- ST_Collect - Return a specified ST_Geometry value from a collection of other geometries.
- ST_ConvexHull - The convex hull of a geometry represents the minimum convex geometry that encloses all geometries within the set.
- ST_CoordDim - Return the coordinate dimension of the ST_Geometry value.
- ST_CurveToLine - Converts a CIRCULARSTRING/CURVEDPOLYGON to a LINESTRING/POLYGON
- ST_Difference - Returns a geometry that represents that part of geometry A that does not intersect with geometry B.
- ST_Dump - Returns a set of geometry_dump (geom,path) rows, that make up a geometry g1.
- ST_DumpPoints - Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.
- ST_DumpRings - Returns a set of geometry_dump rows, representing the exterior and interior rings of a polygon.
- ST_EndPoint - Returns the last point of a LINESTRING geometry as a POINT.
- ST_Extent3D - an aggregate function that returns the box3D bounding box that bounds rows of geometries.
- ST_ExteriorRing - Returns a line string representing the exterior ring of the POLYGON geometry. Return NULL if the geometry is not a polygon. Will not work with MULTIPOLYGON
- ST_ForceRHR - Forces the orientation of the vertices in a polygon to follow the Right-Hand-Rule.
- ST_Force_3D - Forces the geometries into XYZ mode. This is an alias for ST_Force_3DZ.
- ST_Force_3DZ - Forces the geometries into XYZ mode. This is a synonym for ST_Force_3D.
- ST_Force_4D - Forces the geometries into XYZM mode.
- ST_Force_Collection - Converts the geometry into a GEOMETRYCOLLECTION.
- ST_GeomFromEWKB - Return a specified ST_Geometry value from Extended Well-Known Binary representation (EWKB).
- ST_GeomFromEWKT - Return a specified ST_Geometry value from Extended Well-Known Text representation (EWKT).
- ST_GeomFromGML - Takes as input GML representation of geometry and outputs a PostGIS geometry object
- ST_GeomFromKML - Takes as input KML representation of geometry and outputs a PostGIS geometry object
- ST_GeometryN - Return the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or MULTIPOLYGON. Otherwise, return NULL.
- ST_HasArc - Returns true if a geometry or geometry collection contains a circular string
- ST_InteriorRingN - Return the Nth interior linestring ring of the polygon geometry. Return NULL if the geometry is not a polygon or the given N is out of range.
- ST_IsClosed - Returns TRUE if the LINESTRING's start and end points are coincident.
- ST_IsSimple - Returns (TRUE) if this Geometry has no anomalous geometric points, such as self intersection or self tangency.
- ST_Length3D - Returns the 3-dimensional or 2-dimensional length of the geometry if it is a linestring or multi-linestring.
- ST_Length3D_Spheroid - Calculates the length of a geometry on an ellipsoid, taking the elevation into account. This is just an alias for ST_Length_Spheroid.
- ST_Length_Spheroid - Calculates the 2D or 3D length of a linestring/multilinestring on an ellipsoid. This is useful if the coordinates of the geometry are in longitude/latitude and a length is desired without reprojection.
- ST_LineFromMultiPoint - Creates a LineString from a MultiPoint geometry.
- ST_LineToCurve - Converts a LINESTRING/POLYGON to a CIRCULARSTRING, CURVED POLYGON
- ST_Line_Interpolate_Point - 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_Line_Substring - 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_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_M - Return the M coordinate of the point, or NULL if not available. Input must be a point.
- ST_MakeBox3D - Creates a BOX3D defined by the given 3d point geometries.
- ST_MakeLine - Creates a Linestring from point geometries.
- ST_MakePoint - Creates a 2D,3DZ or 4D point geometry.
- ST_MakePolygon - Creates a Polygon formed by the given shell. Input geometries must be closed LINESTRINGS.
- ST_MemUnion - Same as ST_Union, only memory-friendly (uses less memory and more processor time).
- ST_Mem_Size - Returns the amount of space (in bytes) the geometry takes.
- ST_NDims - Returns coordinate dimension of the geometry as a small int. Values are: 2,3 or 4.
- ST_NPoints - Return the number of points (vertexes) in a geometry.
- ST_NRings - If the geometry is a polygon or multi-polygon returns the number of rings.
- ST_Perimeter3D - Returns the 3-dimensional perimeter of the geometry, if it is a polygon or multi-polygon.
- ST_PointFromWKB - Makes a geometry from WKB with the given SRID
- ST_PointN - Return the Nth point in the first linestring or circular linestring in the geometry. Return NULL if there is no linestring in the geometry.
- ST_PointOnSurface - Returns a POINT guaranteed to lie on the surface.
- ST_Polygon - Returns a polygon built from the specified linestring and SRID.
- ST_RemovePoint - Removes point from a linestring. Offset is 0-based.
- ST_Rotate - This is a synonym for ST_RotateZ
- ST_RotateX - Rotate a geometry rotRadians about the X axis.
- ST_RotateY - Rotate a geometry rotRadians about the Y axis.
- ST_RotateZ - Rotate a geometry rotRadians about the Z axis.
- ST_Scale - Scales the geometry to a new size by multiplying the ordinates with the parameters. Ie: ST_Scale(geom, Xfactor, Yfactor, Zfactor).
- ST_SetPoint - Replace point N of linestring with given point. Index is 0-based.
- ST_Shift_Longitude - Reads every point/vertex in every component of every feature in a geometry, and if the longitude coordinate is <0, adds 360 to it. The result would be a 0-360 version of the data to be plotted in a 180 centric map
- ST_SnapToGrid - Snap all points of the input geometry to the grid defined by its origin and cell size. Remove consecutive points falling on the same cell, eventually returning NULL if output points are not enough to define a geometry of the given type. Collapsed geometries in a collection are stripped from it. Useful for reducing precision.
- ST_StartPoint - Returns the first point of a LINESTRING geometry as a POINT.
- ST_Summary - Returns a text summary of the contents of the ST_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_TransScale - Translates the geometry using the deltaX and deltaY args, then scales it using the XFactor, YFactor args, working in 2D only.
- ST_Translate - Translates the geometry to a new location using the numeric parameters as offsets. Ie: ST_Translate(geom, X, Y) or ST_Translate(geom, X, Y,Z).
- ST_X - Return the X coordinate of the point, or NULL if not available. Input must be a point.
- ST_XMax - Returns X maxima of a bounding box 2d or 3d or a geometry.
- ST_XMin - Returns X minima of a bounding box 2d or 3d or a geometry.
- ST_Y - Return the Y coordinate of the point, or NULL if not available. Input must be a point.
- ST_YMax - Returns Y maxima of a bounding box 2d or 3d or a geometry.
- ST_YMin - Returns Y minima of a bounding box 2d or 3d or a geometry.
- ST_Z - Return the Z coordinate of the point, or NULL if not available. Input must be a point.
- ST_ZMax - Returns Z minima of a bounding box 2d or 3d or a geometry.
- ST_ZMin - Returns Z minima of a bounding box 2d or 3d or a geometry.
- ST_Zmflag - Returns ZM (dimension semantic) flag of the geometries as a small int. Values are: 0=2d, 1=3dm, 2=3dz, 3=4d.
- UpdateGeometrySRID - Updates the SRID of all features in a geometry column, geometry_columns metadata and srid table constraint
8.7. PostGIS Curved Geometry Support Functions
The functions given below are PostGIS functions that can use CIRCULARSTRING, CURVEDPOLYGON, and other curved geometry types
- AddGeometryColumn - Adds a geometry column to an existing table of attributes.
- Box2D - Returns a BOX2D representing the maximum extents of the geometry.
- Box3D - Returns a BOX3D representing the maximum extents of the geometry.
- DropGeometryColumn - Removes a geometry column from a spatial table.
- GeometryType - Returns the type of the geometry as a string. Eg: 'LINESTRING', 'POLYGON', 'MULTIPOINT', etc.
- PostGIS_AddBBox - Add bounding box to the geometry.
- PostGIS_DropBBox - Drop the bounding box cache from the geometry.
- PostGIS_HasBBox - Returns TRUE if the bbox of this geometry is cached, FALSE otherwise.
- ST_Accum - Aggregate. Constructs an array of geometries.
- ST_Affine - Applies a 3d affine transformation to the geometry to do things like translate, rotate, scale in one step.
- ST_AsBinary - Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.
- ST_AsEWKB - Return the Well-Known Binary (WKB) representation of the geometry with SRID meta data.
- ST_AsEWKT - Return the Well-Known Text (WKT) representation of the geometry with SRID meta data.
- ST_AsHEXEWKB - Returns a Geometry in HEXEWKB format (as text) using either little-endian (NDR) or big-endian (XDR) encoding.
- ST_AsText - Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.
- ST_Collect - Return a specified ST_Geometry value from a collection of other geometries.
- ST_CoordDim - Return the coordinate dimension of the ST_Geometry value.
- ST_CurveToLine - Converts a CIRCULARSTRING/CURVEDPOLYGON to a LINESTRING/POLYGON
- ST_Dump - Returns a set of geometry_dump (geom,path) rows, that make up a geometry g1.
- ST_Estimated_Extent - Return the 'estimated' extent of the given spatial table. The estimated is taken from the geometry column's statistics. The current schema will be used if not specified.
- ST_Extent3D - an aggregate function that returns the box3D bounding box that bounds rows of geometries.
- ST_Force_2D - Forces the geometries into a "2-dimensional mode" so that all output representations will only have the X and Y coordinates.
- ST_Force_3D - Forces the geometries into XYZ mode. This is an alias for ST_Force_3DZ.
- ST_Force_3DM - Forces the geometries into XYM mode.
- ST_Force_3DZ - Forces the geometries into XYZ mode. This is a synonym for ST_Force_3D.
- ST_Force_4D - Forces the geometries into XYZM mode.
- ST_Force_Collection - Converts the geometry into a GEOMETRYCOLLECTION.
- ST_GeoHash - Return a GeoHash representation (geohash.org) of the geometry.
- ST_GeogFromWKB - Creates a geography instance from a Well-Known Binary geometry representation (WKB) or extended Well Known Binary (EWKB).
- ST_GeomFromEWKB - Return a specified ST_Geometry value from Extended Well-Known Binary representation (EWKB).
- ST_GeomFromEWKT - Return a specified ST_Geometry value from Extended Well-Known Text representation (EWKT).
- ST_GeomFromText - Return a specified ST_Geometry value from Well-Known Text representation (WKT).
- ST_GeomFromWKB - Creates a geometry instance from a Well-Known Binary geometry representation (WKB) and optional SRID.
- ST_GeometryN - Return the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING, MULTICURVE or MULTIPOLYGON. Otherwise, return NULL.
- = - Returns TRUE if A's bounding box is the same as B's (uses float4 boxes).
- &<| - Returns TRUE if A's bounding box overlaps or is below B's.
- && - Returns TRUE if A's bounding box overlaps B's.
- ST_HasArc - Returns true if a geometry or geometry collection contains a circular string
- ST_IsClosed - Returns TRUE if the LINESTRING's start and end points are coincident.
- ST_IsEmpty - Returns true if this Geometry is an empty geometry . If true, then this Geometry represents the empty point set - i.e. GEOMETRYCOLLECTION(EMPTY).
- ST_LineToCurve - Converts a LINESTRING/POLYGON to a CIRCULARSTRING, CURVED POLYGON
- ST_Mem_Size - Returns the amount of space (in bytes) the geometry takes.
- ST_NPoints - Return the number of points (vertexes) in a geometry.
- ST_NRings - If the geometry is a polygon or multi-polygon returns the number of rings.
- ST_PointFromWKB - Makes a geometry from WKB with the given SRID
- ST_PointN - Return the Nth point in the first linestring or circular linestring in the geometry. Return NULL if there is no linestring in the geometry.
- ST_Rotate - This is a synonym for ST_RotateZ
- ST_RotateZ - Rotate a geometry rotRadians about the Z axis.
- ST_SRID - Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table.
- ST_Scale - Scales the geometry to a new size by multiplying the ordinates with the parameters. Ie: ST_Scale(geom, Xfactor, Yfactor, Zfactor).
- ST_SetSRID - Sets the SRID on a geometry to a particular integer value.
- ST_TransScale - Translates the geometry using the deltaX and deltaY args, then scales it using the XFactor, YFactor args, working in 2D only.
- ST_Transform - Returns a new geometry with its coordinates transformed to the SRID referenced by the integer parameter.
- ST_Translate - Translates the geometry to a new location using the numeric parameters as offsets. Ie: ST_Translate(geom, X, Y) or ST_Translate(geom, X, Y,Z).
- ST_XMax - Returns X maxima of a bounding box 2d or 3d or a geometry.
- ST_XMin - Returns X minima of a bounding box 2d or 3d or a geometry.
- ST_YMax - Returns Y maxima of a bounding box 2d or 3d or a geometry.
- ST_YMin - Returns Y minima of a bounding box 2d or 3d or a geometry.
- ST_ZMax - Returns Z minima of a bounding box 2d or 3d or a geometry.
- ST_ZMin - Returns Z minima of a bounding box 2d or 3d or a geometry.
- ST_Zmflag - Returns ZM (dimension semantic) flag of the geometries as a small int. Values are: 0=2d, 1=3dm, 2=3dz, 3=4d.
- UpdateGeometrySRID - Updates the SRID of all features in a geometry column, geometry_columns metadata and srid table constraint
8.8. PostGIS Function Support Matrix
Below is an alphabetical listing of spatial specific functions in PostGIS and the kinds of spatial
types they work with or OGC/SQL compliance they try to conform to.
- A means the function works with the type or subtype natively.
- A means it works but with a transform cast built-in using cast to geometry, transform to a "best srid" spatial ref and then cast back. Results may not be as expected for large areas or areas at poles
and may accumulate floating point junk.
- A means the function works with the type because of a auto-cast to another such as to box3d rather than direct type support.
8.9. New PostGIS Functions
8.9.1. PostGIS Functions new, behavior changed, or enhanced in 1.5
The functions given below are PostGIS functions that were introduced or enhanced in this major release.
- PostGIS_LibXML_Version - Availability: 1.5 Returns the version number of the libxml2 library.
- ST_AddMeasure - Availability: 1.5.0 Return a derived geometry with measure elements linearly interpolated between the start and end points. If the geometry has no measure dimension, one is added. If the geometry has a measure dimension, it is over-written with new values. Only LINESTRINGS and MULTILINESTRINGS are supported.
- ST_AsBinary - Availability: 1.5.0 geography support was introduced. Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.
- ST_AsGeoJSON - Availability: 1.5.0 geography support was introduced. Return the geometry as a GeoJSON element.
- ST_AsText - Availability: 1.5 - support for geography was introduced. Return the Well-Known Text (WKT) representation of the geometry/geography without SRID metadata.
- ST_Buffer - Availability: 1.5 - ST_Buffer was enhanced to support different endcaps and join types. These are useful for example to convert road linestrings
into polygon roads with flat or square edges instead of rounded edges. Thin wrapper for geography was added. - requires GEOS >= 3.2 to take advantage of advanced geometry functionality.
(T) For geometry: Returns a geometry that represents all points whose distance from this Geometry is less than or equal to distance. Calculations are in the Spatial Reference System of this Geometry. For geography: Uses a planar transform wrapper. Introduced in 1.5 support for different end cap and mitre settings to control shape. buffer_style options: quad_segs=#,endcap=round|flat|square,join=round|mitre|bevel,mitre_limit=#.#
- ST_ClosestPoint - Availability: 1.5.0 Returns the 2-dimensional point on g1 that is closest to g2. This is the first point of the shortest line.
- ST_CollectionExtract - Availability: 1.5.0 Given a GEOMETRYCOLLECTION, returns a MULTI* geometry consisting only of the specified type. Sub-geometries that are not the specified type are ignored. If there are no sub-geometries of the right type, an EMPTY collection will be returned. Only points, lines and polygons are supported. Type numbers are 1 == POINT, 2 == LINESTRING, 3 == POLYGON.
- ST_Covers - Availability: 1.5 - support for geography was introduced. Returns 1 (TRUE) if no point in Geometry B is outside Geometry A. For geography: if geography point B is not outside Polygon Geography A
- ST_DFullyWithin - Availability: 1.5.0 Returns true if all of the geometries are within the specified distance of one another
- ST_DWithin - Availability: 1.5.0 support for geography was introduced 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_Distance - Availability: 1.5.0 geography support was introduced in 1.5. Speed improvements for planar to better handle large or many vertex geometries For geometry type Returns the 2-dimensional cartesian minimum distance (based on spatial ref) between two geometries in projected units. For geography type defaults to return spheroidal minimum distance between two geographies in meters.
- ST_Distance_Sphere - Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points. Returns minimum distance in meters between two lon/lat geometries. Uses a spherical earth and radius of 6370986 meters. Faster than ST_Distance_Spheroid, but less accurate. PostGIS versions prior to 1.5 only implemented for points.
- ST_Distance_Spheroid - Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points. Returns the minimum distance between two lon/lat geometries given a particular spheroid. PostGIS versions prior to 1.5 only support points.
- ST_DumpPoints - Availability: 1.5.0 Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.
- ST_Envelope - Availability: 1.5.0 behavior changed to output double precision instead of float4 Returns a geometry representing the double precision (float8) bounding box of the supplied geometry.
- ST_GMLToSQL - Availability: 1.5 Return a specified ST_Geometry value from GML representation. This is an alias name for ST_GeomFromGML
- ST_GeomFromGML - Availability: 1.5 Takes as input GML representation of geometry and outputs a PostGIS geometry object
- ST_GeomFromKML - Availability: 1.5 Takes as input KML representation of geometry and outputs a PostGIS geometry object
- && - Availability: 1.5.0 support for geography was introduced. Returns TRUE if A's bounding box overlaps B's.
- ~= - Availability: 1.5.0 changed behavior Returns TRUE if A's bounding box is the same as B's.
- ST_HausdorffDistance - Availability: 1.5.0 - requires GEOS >= 3.2.0 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_Intersection - Availability: 1.5 support for geography data type was introduced. (T) Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation does a transform to geometry to do the intersection and then transform back to WGS84.
- ST_Intersects - Availability: 1.5 support for geography was introduced. Returns TRUE if the Geometries/Geography "spatially intersect" - (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 - Availability: 1.5.0 geography support was introduced in 1.5. 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_LongestLine - Availability: 1.5.0 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_MakeEnvelope - Availability: 1.5 Creates a rectangular Polygon formed from the given minimums and maximums. Input values must be in SRS specified by the SRID.
- ST_MaxDistance - Availability: 1.5.0 Returns the 2-dimensional largest distance between two geometries in projected units.
- ST_ShortestLine - Availability: 1.5.0 Returns the 2-dimensional shortest line between two geometries
8.9.2. PostGIS Functions new, behavior changed, or enhanced in 1.4
The functions given below are PostGIS functions that were introduced or enhanced in the 1.4 release.
- Populate_Geometry_Columns - Ensures geometry columns have appropriate spatial constraints and exist in the geometry_columns table. Availability: 1.4.0
- ST_AsSVG - Returns a Geometry in SVG path data given a geometry or geography object.
Availability: 1.2.2 . Availability: 1.4.0 Changed in PostGIS 1.4.0 to include L command in absolute path to conform to http://www.w3.org/TR/SVG/paths.html#PathDataBNF
- ST_Collect - Return a specified ST_Geometry value from a collection of other geometries. Availability: 1.4.0 - ST_Collect(geomarray) was introduced. ST_Collect was enhanced to handle more geometries faster.
- 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. Availability: 1.4.0 - requires GEOS >= 3.1.0.
- ST_Extent - an aggregate function that returns the bounding box that bounds rows of geometries.
Availability: 1.4.0 As of 1.4.0 now returns a box3d_extent instead of box2d object.
- ST_GeoHash - Return a GeoHash representation (geohash.org) of the geometry. Availability: 1.4.0
- ST_IsValidReason - Returns text stating if a geometry is valid or not and if not valid, a reason why. Availability: 1.4 - requires GEOS >= 3.1.0.
- ST_LineCrossingDirection - Given 2 linestrings, returns a number between -3 and 3 denoting what kind of crossing behavior. 0 is no crossing. Availability: 1.4
- 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. Availability: 1.4.0
- ST_MakeLine - Creates a Linestring from point geometries. Availability: 1.4.0 - ST_MakeLine(geomarray) was introduced. ST_MakeLine aggregate functions was enhanced to handle more points faster.
- ST_MinimumBoundingCircle - Returns the smallest circle polygon that can fully contain a geometry. Default uses 48 segments per quarter circle. Availability: 1.4.0 - requires GEOS
- ST_Union - Returns a geometry that represents the point set union of the Geometries. Availability: 1.4.0 - ST_Union was enhanced. ST_Union(geomarray) was introduced and also faster aggregate collection in PostgreSQL. If you are using GEOS 3.1.0+
ST_Union will use the faster Cascaded Union algorithm described in
http://blog.cleverelephant.ca/2009/01/must-faster-unions-in-postgis-14.html
8.9.3. PostGIS Functions new in 1.3
The functions given below are PostGIS functions that were introduced in the 1.3 release.
- ST_AsGeoJSON - Return the geometry as a GeoJSON element. Availability: 1.3.4
- 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. Availability: 1.3.3