📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

ST_BUFFER



Returns a GEOMETRY representing all points whose distance from the input geometry is less than or equal to the specified distance. The result is a MultiPolygon or NULL.

Syntax

ST_BUFFER(<geometry>, <distance>)

Arguments

ArgumentsDescription
<geometry>A GEOMETRY expression. GeometryCollection is not supported.
<distance>Buffer distance. Units match the coordinate system of the input geometry.

Return Type

Geometry (nullable).

Examples

-- Buffer a point (produces a polygon approximating a circle) SELECT ST_BUFFER(TO_GEOMETRY('POINT(0 0)'), 1) IS NOT NULL; ┌────────┐ │ result │ ├────────┤ │ true │ └────────┘ -- Zero distance on a polygon returns itself as MultiPolygon SELECT ST_ASWKT( ST_BUFFER(TO_GEOMETRY('POLYGON((0 0, 4 0, 4 4, 0 4, 0 0))'), 0) ); ┌─────────────────────────────────────────────────┐ │ result │ ├─────────────────────────────────────────────────┤ │ MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0))) │ └─────────────────────────────────────────────────┘ -- Zero distance on a point returns NULL SELECT ST_ASWKT(ST_BUFFER(TO_GEOMETRY('POINT(0 0)'), 0)); ┌────────┐ │ result │ ├────────┤ │ NULL │ └────────┘ -- SRID is preserved SELECT ST_SRID(ST_BUFFER(ST_GEOMETRYFROMWKT('POINT(0 0)', 4326), 1)); ┌────────┐ │ result │ ├────────┤ │ 4326 │ └────────┘

Was this page helpful?