Chapter 8. PostGIS Reference
Prev |  | Next

# Chapter 8. PostGIS Reference

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

## 8.2. Table Management Functions

Abstract

These functions assist in defining tables containing geometry columns.

## 8.3. Geometry Constructors

## 8.4. Geometry Accessors

## 8.5. Geometry Editors

Abstract

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

## 8.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.

## 8.7. Spatial Reference System Functions

Abstract

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

## 8.8. Geometry Input

Abstract

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

### 8.8.1. Well-Known Text (WKT)

### 8.8.2. Well-Known Binary (WKB)

### 8.8.3. Other Formats

## 8.9. Geometry Output

Abstract

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

### 8.9.1. Well-Known Text (WKT)

### 8.9.2. Well-Known Binary (WKB)

### 8.9.3. Other Formats

## 8.10. Operators

### 8.10.1. Bounding Box Operators

### 8.10.2. Distance Operators

## 8.11. Spatial Relationships

Abstract

These functions determine spatial relationships between geometries.

### 8.11.1. Topological Relationships

### 8.11.2. Distance Relationships

## 8.12. Measurement Functions

Abstract

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

## 8.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.

## 8.14. Geometry Processing

Abstract

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

## 8.15. Affine Transformations

Abstract

These functions change the position and shape of geometries using affine transformations.

## 8.16. Clustering Functions

Abstract

These functions implement clustering algorithms for sets of geometries.

## 8.17. 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 15.7, “PostGIS Box Functions”.

## 8.18. Linear Referencing

## 8.19. 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.

## 8.20. SFCGAL Functions

Abstract

SFCGAL is a C++ wrapper library around CGAL that provides advanced 2D and 3D spatial functions. For robustness, geometry coordinates have an exact rational number representation.

Installation instructions for the library can be found on the SFCGAL home page (http://www.sfcgal.org). To enable the functions use `create extension postgis_sfcgal`.

## 8.21. Long Transaction Support

Abstract

These functions implement a row locking mechanism to support long transactions. They are provided primarily for implementors of the Web Feature Service specification.

For the locking mechanism to operate correctly the serializable transaction isolation level must be used.

## 8.22. Version Functions

Abstract

These functions report and upgrade PostGIS versions.

## 8.23. 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.

## 8.24. 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.

Prev |  | Next
Chapter 7. Building Applications | Home | box2d