- Categories:
ST_ BUFFER¶
Returns a GEOMETRY object that represents a MultiPolygon containing the points within a specified distance of the input GEOMETRY object. The returned object effectively represents a “buffer” around the input object.
You can also “shrink” the input object by specifying a negative value for the distance.
Syntax¶
Arguments¶
geometry_expressionThe argument must be an expression of type GEOMETRY.
distanceThe distance from the GEOMETRY object. To “shrink” the object, you can specify a negative value for the distance.
The units depend on the spatial reference system identifier (SRID) of the GEOMETRY object. For example, ESPG:4326 units are degrees, while ESPG:25855 units are meters.
Returns¶
Returns a GEOMETRY object.
Usage notes¶
- SRIDs are based on the EPSG standard (v10.082). For example, the SRID 4326 corresponds to the authority EPSG with the code 4326.
- ST_BUFFER uses eight segments to approximate a quarter circle.
- If
distanceis a negative value, the returned object is smaller than the input object. You can use this to remove small irregularities from the shape. - For LineStrings, the endcap and join styles are always round.
- LineStrings are always buffered on both sides.
Examples¶
Before executing the examples, set the GEOMETRY_OUTPUT_FORMAT parameter to WKT:
The following example returns a Polygon around a Point with a radius of one:
The following example uses a negative value for distance to remove small irregularities (such as spikes) from the shape.
The TO_GEOMETRY call passes in TRUE as the second argument, which allows the function to create a GEOMETRY
object for an invalid shape.