v1.6.0):
The optional third parameter, useSpheroid, controls the mode of buffer calculation.
- Planar Buffering (default): When
useSpheroidis false,ST_Bufferperforms standard planar buffering based on the provided parameters. - Spheroidal Buffering:
- When
useSpheroidis set to true, the function returns the spheroidal buffer polygon for more accurate representation over the Earth. In this mode, the unit of the buffer distance is interpreted as meters. - ST_Buffer first determines the most appropriate Spatial Reference Identifier (SRID) for a given geometry, based on its spatial extent and location, using
ST_BestSRID. - The geometry is then transformed from its original SRID to the selected SRID. If the input geometry does not have a set SRID,
ST_Bufferdefaults to using WGS 84 (SRID 4326) as its original SRID. - The standard planar buffer operation is then applied in this coordinate system.
- Finally, the buffered geometry is transformed back to its original SRID, or to WGS 84 if the original SRID was not set.
- When
As of now, spheroidal buffering only supports lon/lat coordinate systems and will throw an
IllegalArgumentException for input geometries in meter based coordinate systems.Spheroidal buffering may not produce accurate output buffer for input geometries larger than a UTM zone.
quad_segs=#: Number of line segments utilized to approximate a quarter circle (default is 8).endcap=round|flat|square: End cap style (default isround).buttis an accepted synonym forflat.join=round|mitre|bevel: Join style (default isround).miteris an accepted synonym formitre.mitre_limit=#.#: mitre ratio limit and it only affects mitred join style.miter_limitis an accepted synonym formitre_limit.side=both|left|right: Defaults toboth. Settingleftorrightenables a single-sided buffer operation on the geometry, with the buffered side aligned according to the direction of the line. This functionality is specific to LINESTRING geometry and has no impact on POINT or POLYGON geometries. By default, square end caps are applied whenleftorrightare specified.
ST_Buffer throws an IllegalArgumentException if the correct format, parameters, or options are not provided.Signatures
Parameters
The input geometry.
The buffer distance.
Whether to use spheroidal distance calculation.
The buffer style parameters value.
Return type
The resulting geometry.
Examples





