名称

ST_最小外接圆 — 返回包含几何图形的最小圆形多边形。

概要

geometry ST_MinimumBoundingCircle(geometry geomA, integer num_segs_per_qt_circ=48);

描述

返回包含几何图形的最小圆形多边形。

[Note]

外接圆由一个多边形近似表示,默认情况下每个四分之一圆有 48 个线段。由于多边形是最小外接圆的近似值,因此输入几何图形中的某些点可能不包含在该多边形内。可以通过增加线段数量来提高近似精度。对于不适合使用近似值的应用,可以使用 ST_MinimumBoundingRadius

ST_Collect 一起使用可获取一组几何图形的最小外接圆。

要计算位于最小圆上的两个点(“最大直径”),请使用 ST_LongestLine

多边形的面积除以其最小外接圆的面积之比称为 Reock 紧凑度得分

由 GEOS 模块执行。

可用性: 1.4.0

示例

SELECT d.disease_type,
    ST_MinimumBoundingCircle(ST_Collect(d.geom)) As geom
    FROM disease_obs As d
    GROUP BY d.disease_type;

一个点和线串的最小外接圆。使用 8 个线段来近似一个四分之一圆

SELECT ST_AsText(ST_MinimumBoundingCircle(
        ST_Collect(
            ST_GeomFromText('LINESTRING(55 75,125 150)'),
                ST_Point(20, 80)), 8
                )) As wktmbc;
wktmbc
-----------
POLYGON((135.59714732062 115,134.384753327498 102.690357210921,130.79416296937 90.8537670908995,124.963360620072 79.9451031602111,117.116420743937 70.3835792560632,107.554896839789 62.5366393799277,96.6462329091006 56.70583703063,84.8096427890789 53.115246672502,72.5000000000001 51.9028526793802,60.1903572109213 53.1152466725019,48.3537670908996 56.7058370306299,37.4451031602112 62.5366393799276,27.8835792560632 70.383579256063,20.0366393799278 79.9451031602109,14.20583703063 90.8537670908993,10.615246672502 102.690357210921,9.40285267938019 115,10.6152466725019 127.309642789079,14.2058370306299 139.1462329091,20.0366393799275 150.054896839789,27.883579256063 159.616420743937,
37.4451031602108 167.463360620072,48.3537670908992 173.29416296937,60.190357210921 176.884753327498,
72.4999999999998 178.09714732062,84.8096427890786 176.884753327498,96.6462329091003 173.29416296937,107.554896839789 167.463360620072,
117.116420743937 159.616420743937,124.963360620072 150.054896839789,130.79416296937 139.146232909101,134.384753327498 127.309642789079,135.59714732062 115))