ST_MinimumBoundingCircle

更新时间:
复制 MD 格式

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

ParameterTypeDescriptionDefault
geomAgeometryThe input geometry object.
numSegsPerQtCircintegerNumber 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 numSegsPerQtCirc value produces a more accurate result, but performance may deteriorate.

  • MULTI and GeometryCollection support: Works with MULTI and GeometryCollection geometry types in most cases.

  • Aggregate usage: ST_MinimumBoundingCircle is not an aggregate function. To compute the bounding circle over a set of geometry objects, combine it with ST_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;
1

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 a GeometryCollection, used as input for set-level bounding circle calculations.