﻿---
title: ES|QL ST_BUFFER function
description: 
url: https://www.elastic.co/elastic/docs-builder/docs/3243/reference/query-languages/esql/functions-operators/spatial-functions/st_buffer
products:
  - Elasticsearch
---

# ES|QL ST_BUFFER function
<applies-to>
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Preview since 9.4
</applies-to>


## Syntax

![Embedded](https://www.elastic.co/elastic/docs-builder/docs/3243/reference/query-languages/esql/images/functions/st_buffer.svg)


## Parameters

<definitions>
  <definition term="geometry">
    Expression of type `geo_point`, `geo_shape`, `cartesian_point` or `cartesian_shape`. If `null`, the function returns `null`.
  </definition>
  <definition term="distance">
    Buffer distance in the units of the input spatial reference system
  </definition>
</definitions>


## Description

Computes a buffer area around the input geometry at the specified distance. The distance is in the units of the input spatial reference system. Positive distances expand the geometry, negative distances shrink it. A distance of zero will return the input geometry unchanged. Points and lines become polygons when buffered, unless a zero distance is provided.

## Supported types


| geometry        | distance | result          |
|-----------------|----------|-----------------|
| cartesian_point | double   | cartesian_shape |
| cartesian_point | float    | cartesian_shape |
| cartesian_point | integer  | cartesian_shape |
| cartesian_point | long     | cartesian_shape |
| cartesian_shape | double   | cartesian_shape |
| cartesian_shape | float    | cartesian_shape |
| cartesian_shape | integer  | cartesian_shape |
| cartesian_shape | long     | cartesian_shape |
| geo_point       | double   | geo_shape       |
| geo_point       | float    | geo_shape       |
| geo_point       | integer  | geo_shape       |
| geo_point       | long     | geo_shape       |
| geo_shape       | double   | geo_shape       |
| geo_shape       | float    | geo_shape       |
| geo_shape       | integer  | geo_shape       |
| geo_shape       | long     | geo_shape       |


## Example

```esql
ROW wkt = "POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))"
| EVAL buffered = ST_BUFFER(TO_GEOSHAPE(wkt), -1)
```


| wkt:keyword                         | buffered:geo_shape                                      |
|-------------------------------------|---------------------------------------------------------|
| POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0)) | POLYGON ((1.0 1.0, 1.0 3.0, 3.0 3.0, 3.0 1.0, 1.0 1.0)) |


### Diagrams

**Negative distance shrinks a polygon**
Buffering a 10x10 square by `-2` produces a smaller square inset by 2 units on each side.
![Negative distance shrinks a polygon](https://www.elastic.co/elastic/docs-builder/docs/3243/reference/query-languages/esql/images/functions/st_buffer_shrink_polygon.svg)

**Buffering a point produces a circle**
A point with positive distance becomes a polygon approximating a circle (8 segments per quadrant by default).
![Buffering a point produces a circle](https://www.elastic.co/elastic/docs-builder/docs/3243/reference/query-languages/esql/images/functions/st_buffer_point.svg)

**Default round end caps on a line**
A line buffered with the default round end caps becomes a stadium shape.
![Default round end caps on a line](https://www.elastic.co/elastic/docs-builder/docs/3243/reference/query-languages/esql/images/functions/st_buffer_line_round.svg)