Type to search.

ES|QL ST_BUFFER function

Serverless Preview

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Preview

    This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply.

Serverless interfaces and procedures might differ from classic Elastic Stack deployments.

Stack Preview 9.4+

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Preview since 9.4

    This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply.

Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

Computes a buffer area around the input geometry at the specified distance.

Embedded
Embedded
geometry
Expression of type geo_point, geo_shape, cartesian_point or cartesian_shape. If null, the function returns null.
distance
Buffer distance in the units of the input spatial reference system
options Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability Preview This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Preview since 9.5 This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

(Optional) ST_BUFFER additional options like quad_segs, endcap, join and mitre_limit.

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.

geometry distance options 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
quad_segs Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability Preview This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Preview since 9.5 This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
(integer) Number of line segments used to approximate a quarter circle. Defaults to 8.
endcap Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability Preview This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Preview since 9.5 This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
(keyword) End cap style for buffering linear geometries. Defaults to round.
join Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability Preview This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Preview since 9.5 This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
(keyword) Join style for buffering. Defaults to round.
mitre_limit Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability Preview This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Preview since 9.5 This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

(double) Mitre ratio limit, only meaningful when join=mitre. Defaults to 5.0.

ES|QL
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))

The optional options argument can configure end caps and join styles. Combining endcap=flat with join=mitre produces sharp corners on a buffered L-shape:

ES|QL
ROW geom = TO_CARTESIANSHAPE("LINESTRING(0 0, 10 0, 10 10)")
| EVAL buffered = ST_BUFFER(geom, 2, {"endcap": "flat", "join": "mitre"})
| KEEP buffered
buffered:cartesian_shape
POLYGON ((8.0 2.0, 8.0 10.0, 12.0 10.0, 12.0 -2.0, 0.0 -2.0, 0.0 2.0, 8.0 2.0))

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
Negative distance shrinks a polygon

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
Buffering a point produces a circle

Default round end caps on a line

A line buffered with default options has rounded end caps (endcap=round).

Default round end caps on a line
Default round end caps on a line

Flat end caps on a line

Setting endcap=flat keeps the buffer flush with the line's endpoints.

Flat end caps on a line
Flat end caps on a line

Square end caps on a line

endcap=square extends the buffer past each endpoint by the buffer distance.

Square end caps on a line
Square end caps on a line

Mitre joins on a buffered corner

join=mitre produces sharp corners. Combined with endcap=flat you get a clean rectangle for a buffered L-shape.

Mitre joins on a buffered corner
Mitre joins on a buffered corner