Share via


st_buffer function

Applies to: check marked yes Databricks Runtime 17.1 and above

Important

This feature is in Public Preview.

Returns the buffer of the input GEOMETRY using the specified radius.

Syntax

st_buffer ( geoExpr, radiusExpr )

Arguments

  • geoExpr: A GEOMETRY value.
  • radiusExpr: A DOUBLE value as radius of the buffer. The unit of the radius are those of the coordinate reference system of the geometry.

Returns

Returns the buffer of the input GEOMETRY using the specified radius. The buffer is the Minkowski sum (if the radius is non-negative) or the Minkowski difference (if the radius is negative) of this geometry with a disk whose radius is the given radius radiusExpr. The boundary of the result consists, in theory, of circles or circular arcs. Here we approximate these arcs with polylines, and return the result as a geometry value. The result is always a 2D polygon or multipolygon (Z and M coordinates in the input are dropped).

Examples

-- Expands a point into a circle-like polygon with a 1-unit radius.
> SELECT st_astext(st_envelope(st_buffer(st_geomfromtext('POINT(0 0)'), 1)));
  POLYGON((-1 -1,-1 1,1 1,1 -1,-1 -1))

-- Shrinks a small polygon so much that nothing is left
> SELECT st_astext(st_buffer(st_geomfromtext('POLYGON((0 0,2 0,2 2,0 2,0 0))'), -5))
  POLYGON EMPTY