ST_MinimumBoundingRadius

更新时间:
复制 MD 格式

Returns the center point and radius of the minimum bounding circle of a geometry.

Syntax

(geometry, double precision) ST_MinimumBoundingRadius(geometry geom);

Parameters

ParameterDescription
geomThe input geometry.

Return value

Returns a composite record with two fields:

FieldTypeDescription
centergeometryThe center point of the minimum bounding circle.
radiusdouble precisionThe radius of the minimum bounding circle.

Description

ST_MinimumBoundingRadius computes the center point and radius of the minimum bounding circle — the smallest circle that fully contains the input geometry.

To get the minimum bounding circle of a set of geometries, combine it with ST_Collect.

Examples

The following example computes the minimum bounding circle of a diamond-shaped polygon:

SELECT ST_AsText(center), radius
FROM ST_MinimumBoundingRadius('POLYGON((0 1,-1 0,0 -1,1 0,0 1))'::geometry);

Output:

 st_astext  | radius
------------+--------
 POINT(0 0) |      1
(1 row)

The center is at the origin (0, 0) and the radius is 1.

See also

  • ST_Collect — aggregates geometries into a geometry collection