ST_Buffer¶
Computes a geometry or geography that represents all points whose distance from the input is less than or equal to a specified distance.
Usage¶
geometry ST_Buffer(geom: geometry, distance: float64)
geometry ST_Buffer(geom: geometry, distance: float64, params: string)
geography ST_Buffer(geog: geography, distance: float64)
geography ST_Buffer(geog: geography, distance: float64, num_quad_segs: integer)
geography ST_Buffer(geog: geography, distance: float64, params: string)
Arguments¶
- geog (geography): Input geography
- distance (float64): Radius of the buffer
- params (string): Space-separated
key=valueparameters. Supported parameters includequad_segs,endcap,join,mitre_limit, andside. These parameters are identical to the PostGIS buffer parameter strings. - num_quad_segs (integer)
- geom (geometry): Input geometry
Description¶
For geography, the distance is specified in meters. The buffer is computed on the sphere, producing a result that considers polar regions and the antimeridian. Negative distances are supported for polygon inputs to shrink the polygon.
Examples¶
SELECT ST_Buffer(
ST_GeomFromText('POLYGON ((10 10, 11 10, 10 11, 10 10))'),
1.0
) AS geom;
┌──────────────────────────────────────────────────────────────────────────────┐
│ geom │
│ geometry │
╞══════════════════════════════════════════════════════════════════════════════╡
│ MULTIPOLYGON(((9 11,9 10,9.01921471953392 9.8049096763134,9.076120465993881… │
└──────────────────────────────────────────────────────────────────────────────┘
SELECT ST_Buffer(
ST_GeomFromText('POLYGON ((10 10, 11 10, 10 11, 10 10))'),
1.0,
'quad_segs=2'
) AS geom;
┌──────────────────────────────────────────────────────────────────────────────┐
│ geom │
│ geometry │
╞══════════════════════════════════════════════════════════════════════════════╡
│ POLYGON((9 10,9 11,9.292893218813452 11.707106781186548,10 12,10.7071067811… │
└──────────────────────────────────────────────────────────────────────────────┘
For geography, the distance is specified in meters:
SELECT ST_Buffer(
ST_GeogFromText('POLYGON ((10 10, 11 10, 10 11, 10 10))'),
1000
);
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_buffer(st_geogfromtext(Utf8("POLYGON ((10 10, 11 10, 10 11, 10 10))")),In │
│ t64(1000))… │
╞══════════════════════════════════════════════════════════════════════════════╡
│ POLYGON((10.00001383818074 9.991006808382576,10.999986161819258 9.991006808… │
└──────────────────────────────────────────────────────────────────────────────┘

