

© 2025 by The Clinic. Powered and secured by Wix
MySQL:
ST_BUFFER
ST_Buffer(g, d[, strategy1[, strategy2[, strategy3]]])
Returns a geometry that represents all points whose distance from the
geometry value g is less than or equal to a distance of d.
If the geometry argument is empty, ST_Buffer() returns an empty
geometry.
If the distance is 0, ST_Buffer() returns the geometry argument
unchanged:
mysql> SET @pt = ST_GeomFromText('POINT(0 0)');
mysql> SELECT ST_AsText(ST_Buffer(@pt, 0));
+------------------------------+
| ST_AsText(ST_Buffer(@pt, 0)) |
+------------------------------+
| POINT(0 0) |
+------------------------------+
ST_Buffer() supports negative distances for Polygon and MultiPolygon
values, and for geometry collections containing Polygon or MultiPolygon
values. The result may be an empty geometry.
ST_Buffer() permits up to three optional strategy arguments following
the distance argument. Strategies influence buffer computation. These
arguments are byte string values produced by the ST_Buffer_Strategy()
function, to be used for point, join, and end strategies:
o Point strategies apply to Point and MultiPoint geometries. If no
point strategy is specified, the default is
ST_Buffer_Strategy('point_circle', 32).
o Join strategies apply to LineString, MultiLineString, Polygon, and
MultiPolygon geometries. If no join strategy is specified, the
default is ST_Buffer_Strategy('join_round', 32).
o End strategies apply to LineString and MultiLineString geometries. If
no end strategy is specified, the default is
ST_Buffer_Strategy('end_round', 32).
Up to one strategy of each type may be specified, and they may be given
in any order.
ST_Buffer() handles its arguments as described in the introduction to
this section, with these exceptions:
o For a negative distance for Point, MultiPoint, LineString, and
MultiLineString values, and for geometry collections not containing
any Polygon or MultiPolygon values, an ER_WRONG_ARGUMENTS
(https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference
.html#error_er_wrong_arguments) error occurs.
o If multiple strategies of a given type are specified, an
ER_WRONG_ARGUMENTS
(https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference
.html#error_er_wrong_arguments) error occurs.
URL: https://dev.mysql.com/doc/refman/8.0/en/spatial-operator-functions.html
Example
mysql> SET @pt = ST_GeomFromText('POINT(0 0)');
mysql> SET @pt_strategy = ST_Buffer_Strategy('point_square');
mysql> SELECT ST_AsText(ST_Buffer(@pt, 2, @pt_strategy));
+--------------------------------------------+
| ST_AsText(ST_Buffer(@pt, 2, @pt_strategy)) |
+--------------------------------------------+
| POLYGON((-2 -2,2 -2,2 2,-2 2,-2 -2)) |
+--------------------------------------------+
mysql> SET @ls = ST_GeomFromText('LINESTRING(0 0,0 5,5 5)');
mysql> SET @end_strategy = ST_Buffer_Strategy('end_flat');
mysql> SET @join_strategy = ST_Buffer_Strategy('join_round', 10);
mysql> SELECT ST_AsText(ST_Buffer(@ls, 5, @end_strategy, @join_strategy))
+---------------------------------------------------------------+
| ST_AsText(ST_Buffer(@ls, 5, @end_strategy, @join_strategy)) |
+---------------------------------------------------------------+
| POLYGON((5 5,5 10,0 10,-3.5355339059327373 8.535533905932738, |
| -5 5,-5 0,0 0,5 0,5 5)) |
+---------------------------------------------------------------+