Functions that create new geometries with different space configurations
Using existing geometries as a starting point, the following functions create new geometries that represent circular areas or other configurations of space.
For example, given a point that represents the center of a proposed airport, ST_Buffer can create a surface that represents, in circular form, the proposed extent of the airport.
ST_Buffer
The ST_Buffer function can generate a new geometry that extends outward from an existing geometry by a specified radius.
The new geometry is a surface when the existing geometry is buffered or whenever the elements of a collection are so close that the buffers around the single elements of the collection overlap. However, when the buffers are separate, individual buffer surfaces result, in which case ST_Buffer returns a multisurface.
The ST_Buffer function accepts both positive and negative distance; however, only geometries with a dimension of two (surfaces and multisurfaces) apply a negative buffer. The absolute value of the buffer distance is used whenever the dimension of the source geometry is less than 2 (all geometries that are not surfaces or multisurfaces).
In general, for exterior rings, positive buffer distances generate surface rings that are away from the center of the source geometry; negative buffer distances generate surface or multisurface rings toward the center. For interior rings of a surface or multisurface, a positive buffer distance generates a buffer ring toward the center, and a negative buffer distance generates a buffer ring away from the center.
The buffering process merges surfaces that overlap. Negative distances greater than one half the maximum interior width of a polygon result in an empty geometry.
ST_ConvexHull
The ST_ConvexHull function returns the convex hull of any geometry that has at least three vertices forming a convex.
Vertices are the pairs of X and Y coordinates within geometries. A convex hull is the smallest convex polygon that can be formed by all vertices within a given set of vertices.
ST_Difference
ST_Difference takes two geometries of the same dimension as input and returns that portion of the first geometry that is not intersected by the second geometry.
This operation is the spatial equivalent of the logical operator AND NOT. The portion of geometry returned by ST_Difference is itself a geometry—a collection that has the same dimension as the geometries taken as input. If these two geometries are equal—that is, if they occupy the same space— the returned geometry is empty.
To the left of each arrow are two geometries that are given to ST_Difference as input. To the right of each arrow is the output of ST_Difference. If part of the first geometry is intersected by the second, the output is that part of the first geometry that is not intersected. If the geometries given as input are equal, the output is an empty geometry (denoted by the term nil)
ST_Intersection
The ST_Intersection function returns a set of points, represented as a geometry, that define the intersection of two given geometries.
If the geometries given to ST_Intersection as input do not intersect, or if they do intersect and the dimension of their intersection is less than the geometries' dimensions, ST_Intersection returns an empty geometry.
This figure illustrates ten examples of output for ST_Intersection, which returns information on where given geometries intersect. To the left of each arrow are two intersecting geometries that are given to ST_Intersection as input. To the right of each arrow is the output of ST_Intersection, which is a geometry that represents the intersection created by the geometries at the left.
ST_SymDifference
The ST_SymDifference function returns the symmetric difference (the spatial equivalent of the logical XOR operation) of two intersecting geometries that have the same dimension.
If these geometries are equal, ST_SymDifference returns an empty geometry. If they are not equal, then a portion of one or both of them lies outside the area of intersection.