ST_Buffer — Returns a geometry that represents all points whose distance from this Geometry is less than or equal to distance. Calculations are in the Spatial Reference System of that Geometry.
PostgreSQL
geometry ST_Buffer(
bytea
Geometry, double
distance)
;
geometry ST_Buffer(
bytea
Geometry, double
distance, integer
QuadrantSegments)
;
geometry ST_Buffer(
bytea
Geometry, double
distance, varchar
Buffer_Parameters)
;
H2
geometry ST_Buffer(
bytea
Geometry, double
distance)
;
geometry ST_Buffer(
bytea
Geometry, double
distance, integer
QuadrantSegments)
;
geometry ST_BufferEx(
bytea
Geometry, double
distance, varchar
Buffer_Parameters)
;
Returns a 2D geometry that represents all points whose distance from this Geometry is less than or equal to distance. Calculations are in the Spatial Reference System of the incoming Geometry.
Buffer Parameters
'quad_segs=integer'
QuadrantSegments. Sets the number of line segments in a quarter of a circle.
If quad_segs >= 1, joins are round, and qs indicates the number of segments to use to approximate a quarter-circle.
If quad_segs = 0, joins are beveled
If quad_segs < 0, joins are mitred, and the value of qs indicates the mitre ration limit as mitreLimit = |quad_segs|
'endcap=round|flat|square'
End cap style. Specifies the end cap style of the generated buffer. The styles supported are CAP_ROUND, CAP_FLAT, and CAP_SQUARE. The default is CAP_ROUND.
'join=round|mitre|bevel'
Join style. Sets the join style for outside corners between line segments. Allowable values are JOIN_ROUND (which is the default), JOIN_MITRE and JOIN_BEVEL.
'mitre_limit= double'
Mitre_limit. Limit on the mitre ratio used for very sharp corners. The mitre ratio is the ratio of the distance from the corner to the end of the mitred offset corner. When two line segments meet at a sharp angle, a miter join will extend far beyond the original geometry. To prevent unreasonable geometry, the mitre limit allows controlling the maximum length of the join corner. Corners with a ratio which exceed the limit will be beveled.
This function could be used to clean invalid polygons with a 0 radius, ST_Buffer(geom,0). It is, however, advisable to use ST_CleanPolygon function.
ST_Buffer is sometimes used to make distance queries. It is not advisable because it's much slower than using ST_DWithin.
OGC defines this predicate just as ST_Buffer(geometry, distance) |
2D | 3D | M |
---|---|---|
- | - |
OGC SFS for SQL. 1.1 (1999) | OGC SFS for SQL. 1.1.0 (2005) | OGC SFS for SQL. 1.2.0 (2006) | SQL-MM Part 3 |
---|---|---|---|
- | - | - | - |
8 Quadrant Segments (Default) SELECT ST_Buffer( ST_GeomFromText('POINT (10 10)'),10); | 3 Quadrant Segments (integer) SELECT ST_Buffer( ST_GeomFromText('POINT (10 10)'),10,3); | 1 Quadrant Segments --PostgreSQL SELECT ST_Buffer( ST_GeomFromText('POINT (10 10)') ,10,'quad_segs=1'); --H2 SELECT ST_BufferEx( ST_GeomFromText('POINT (10 10)') ,10,'quad_segs=1'); |
endcap=round (default) --PostgreSQL SELECT ST_Buffer( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'endcap=round'); --H2 SELECT ST_BufferEx( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'endcap=round'); | endcap=flat --PostgreSQL SELECT ST_Buffer( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'endcap=flat'); --H2 SELECT ST_BufferEx( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'endcap=flat'); | endcap=square --PostgreSQL SELECT ST_BufferEx( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'endcap=square'); --H2 SELECT ST_BufferEx( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'endcap=square'); |
join=round (default) --PostgreSQL SELECT ST_Buffer( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=round'); --H2 SELECT ST_BufferEx( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=round'); | join=mitre --PostgreSQL SELECT ST_Buffer( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=mitre'); --H2 SELECT ST_BufferEx( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=mitre'); | join=bevel --PostgreSQL SELECT ST_Buffer( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=bevel'); --H2 SELECT ST_BufferEx( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=bevel'); |
join=mitre mitre_limit=5 --PostgreSQL SELECT ST_Buffer( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=mitre mitre_limit=5'); --H2 SELECT ST_BufferEx( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=mitre mitre_limit=5'); | join=mitre mitre_limit=2 --PostgreSQL SELECT ST_Buffer( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=mitre mitre_limit=2'); --H2 SELECT ST_BufferEx( ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=mitre mitre_limit=2'); | join=mitre mitre_limit=0.5 --PostgreSQL SELECT ST_Buffer (ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=mitre mitre_limit=0.5'); --H2 SELECT ST_BufferEx (ST_GeomFromText ('LINESTRING (1 1, 3 5, 3 2, 3 2, 5 2)') ,0.5,'join=mitre mitre_limit=0.5'); |