Chapter 7. PostGIS Reference (original) (raw)

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.

| [Note] | | | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | | 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. | |

7.1. PostGIS Geometry/Geography/Box Data Types

Abstract

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.

7.2. Table Management Functions

Abstract

These functions assist in defining tables containing geometry columns.

7.3. Geometry Constructors

7.4. Geometry Accessors

7.5. Geometry Editors

Abstract

These functions create modified geometries by changing type, structure or vertices.

7.6. Geometry Validation

Abstract

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.

7.7. Spatial Reference System Functions

Abstract

These functions work with the Spatial Reference System of geometries as defined in the spatial_ref_sys table.

7.8. Geometry Input

Abstract

These functions create geometry objects from various textual or binary formats.

7.8.1. Well-Known Text (WKT)

7.8.2. Well-Known Binary (WKB)

7.8.3. Other Formats

7.9. Geometry Output

Abstract

These functions convert geometry objects into various textual or binary formats.

7.9.1. Well-Known Text (WKT)

7.9.2. Well-Known Binary (WKB)

7.9.3. Other Formats

7.10. Operators

7.10.1. Bounding Box Operators

7.10.2. Distance Operators

7.11. Spatial Relationships

Abstract

These functions determine spatial relationships between geometries.

7.11.1. Topological Relationships

7.11.2. Distance Relationships

7.12. Measurement Functions

Abstract

These functions compute measurements of distance, area and angles. There are also functions to compute geometry values determined by measurements.

7.13. Overlay Functions

Abstract

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.

7.14. Geometry Processing

Abstract

These functions compute geometric constructions, or alter geometry size or shape.

7.15. Coverages

Abstract

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.

7.16. Affine Transformations

7.17. Clustering Functions

Abstract

These functions implement clustering algorithms for sets of geometries.

7.18. Bounding Box Functions

Abstract

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”.

7.19. Linear Referencing

7.20. Trajectory Functions

Abstract

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.

7.21. Version Functions

Abstract

These functions report and upgrade PostGIS versions.

7.22. Grand Unified Custom Variables (GUCs)

Abstract

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.

For more examples of usage refer to SQL SET and SQL ALTER SYSTEM

7.23. Troubleshooting Functions

Abstract

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.