Returns the smallest circle polygon that fully encloses a geometry object, approximated using line segments (default: 48 segments per quarter circle).
Syntax
geometry ST_MinimumBoundingCircle(geometry geomA, integer numSegsPerQtCirc)Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
geomA | geometry | The input geometry object. | — |
numSegsPerQtCirc | integer | Number of line segments used to approximate a quarter circle. A higher value produces a more accurate circle at the cost of performance. | 48 |
Usage notes
Approximation behavior: The returned polygon approximates the true minimum bounding circle. A larger
numSegsPerQtCircvalue produces a more accurate result, but performance may deteriorate.MULTI and GeometryCollection support: Works with MULTI and
GeometryCollectiongeometry types in most cases.Aggregate usage:
ST_MinimumBoundingCircleis not an aggregate function. To compute the bounding circle over a set of geometry objects, combine it withST_Collect:ST_MinimumBoundingCircle(ST_Collect(somepointfield)).
Examples
Compare the minimum bounding circle with input geometry
The following query uses ST_CurveToLine to convert the circle approximation for display alongside the original polygon:
SELECT ST_CurveToLine(ST_MinimumBoundingCircle(g)), g
FROM (
SELECT 'POLYGON((0 0,1 0,1 1,0 1,0 0))'::geometry AS g
) AS t;
Compute the minimum bounding circle for grouped geometry objects
Use ST_Collect with GROUP BY to compute the minimum bounding circle for each group in a dataset. The following example groups spatial observations by type and returns one bounding circle per type:
SELECT
observation_type,
ST_MinimumBoundingCircle(ST_Collect(geom)) AS bounding_circle
FROM spatial_observations
GROUP BY observation_type;See also
ST_Collect— Aggregates geometry objects into aGeometryCollection, used as input for set-level bounding circle calculations.