

 Amazon Redshift will no longer support the use of Python UDFs after June 30, 2026. We will start enforcing it in phases. For more information on the details of Python end of life and migration options, see the [ blog post ](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/) that was published on June 30, 2025. 

# ST\_Buffer
<a name="ST_Buffer-function"></a>

ST\_Buffer returns 2D geometry that represents all points whose distance from the input geometry projected on the xy-Cartesian plane is less than or equal to the input distance. 

## Syntax
<a name="ST_Buffer-function-syntax"></a>

```
ST_Buffer(geom, distance)
```

```
ST_Buffer(geom, distance, number_of_segments_per_quarter_circle)
```

## Arguments
<a name="ST_Buffer-function-arguments"></a>

 *geom*   
A value of data type `GEOMETRY` or an expression that evaluates to a `GEOMETRY` type.

 *distance*   
A value of data type `DOUBLE PRECISION` that represents distance (or radius) of the buffer. 

 *number\_of\_segments\_per\_quarter\_circle*   
A value of data type `INTEGER`. This value determines the number of points to approximate a quarter circle around each vertex of the input geometry. Negative values default to zero. The default is 8.

## Return type
<a name="ST_Buffer-function-return"></a>

`GEOMETRY`

The ST\_Buffer function returns two-dimensional (2D) geometry in the xy-Cartesian plane.

If *geom* is a `GEOMETRYCOLLECTION`, then an error is returned.

## Examples
<a name="ST_Buffer-function-examples"></a>

The following SQL returns the buffer of the input linestring. 

```
SELECT ST_AsEwkt(ST_Buffer(ST_GeomFromText('LINESTRING(1 2,5 2,5 8)'), 2));
```

```
               st_asewkt  
POLYGON((-1 2,-0.96157056080646 2.39018064403226,-0.847759065022573 2.76536686473018,-0.662939224605089 3.11114046603921,-0.414213562373093 3.4142135623731,-0.111140466039201 3.66293922460509,0.234633135269824 3.84775906502257,0.609819355967748 3.96157056080646,1 4,3 4,3 8,3.03842943919354 8.39018064403226,3.15224093497743 8.76536686473018,3.33706077539491 9.11114046603921,3.58578643762691 9.4142135623731,3.8888595339608 9.66293922460509,4.23463313526982 9.84775906502257,4.60981935596775 9.96157056080646,5 10,5.39018064403226 9.96157056080646,5.76536686473018 9.84775906502257,6.11114046603921 9.66293922460509,6.4142135623731 9.41421356237309,6.66293922460509 9.1111404660392,6.84775906502258 8.76536686473017,6.96157056080646 8.39018064403225,7 8,7 2,6.96157056080646 1.60981935596774,6.84775906502257 1.23463313526982,6.66293922460509 0.888859533960796,6.41421356237309 0.585786437626905,6.1111404660392 0.33706077539491,5.76536686473018 0.152240934977427,5.39018064403226 0.0384294391935391,5 0,1 0,0.609819355967744 0.0384294391935391,0.234633135269821 0.152240934977427,-0.111140466039204 0.337060775394909,-0.414213562373095 0.585786437626905,-0.662939224605091 0.888859533960796,-0.847759065022574 1.23463313526982,-0.961570560806461 1.60981935596774,-1 2))
```

The following SQL returns the buffer of the input point geometry which approximates a circle. Because the command doesn't specify the number of segments per quarter circle, the function uses the default value of eight segments to approximate the quarter circle.

```
SELECT ST_AsEwkt(ST_Buffer(ST_GeomFromText('POINT(3 4)'), 2));
```

```
               st_asewkt
POLYGON((1 4,1.03842943919354 4.39018064403226,1.15224093497743 4.76536686473018,1.33706077539491 5.11114046603921,1.58578643762691 5.4142135623731,1.8888595339608 5.66293922460509,2.23463313526982 5.84775906502257,2.60981935596775 5.96157056080646,3 6,3.39018064403226 5.96157056080646,3.76536686473019 5.84775906502257,4.11114046603921 5.66293922460509,4.4142135623731 5.41421356237309,4.66293922460509 5.1111404660392,4.84775906502258 4.76536686473017,4.96157056080646 4.39018064403225,5 4,4.96157056080646 3.60981935596774,4.84775906502257 3.23463313526982,4.66293922460509 2.8888595339608,4.41421356237309 2.58578643762691,4.1111404660392 2.33706077539491,3.76536686473018 2.15224093497743,3.39018064403226 2.03842943919354,3 2,2.60981935596774 2.03842943919354,2.23463313526982 2.15224093497743,1.8888595339608 2.33706077539491,1.58578643762691 2.58578643762691,1.33706077539491 2.8888595339608,1.15224093497743 3.23463313526982,1.03842943919354 3.60981935596774,1 4))
```

The following SQL returns the buffer of the input point geometry which approximates a circle. Because the command specifies 3 as the number of segments per quarter circle, the function uses three segments to approximate the quarter circle.

```
SELECT ST_AsEwkt(ST_Buffer(ST_GeomFromText('POINT(3 4)'), 2, 3));
```

```
               st_asewkt
POLYGON((1 4,1.26794919243112 5,2 5.73205080756888,3 6,4 5.73205080756888,4.73205080756888 5,5 4,4.73205080756888 3,4 2.26794919243112,3 2,2 2.26794919243112,1.26794919243112 3,1 4))
```