ST_MaximumInscribedCircle¶
Introduction: Finds the largest circle that is contained within a (multi)polygon, or which does not overlap any lines and points. Returns a row with fields:
center- center point of the circlenearest- nearest point from the center of the circleradius- radius of the circle
For polygonal geometries, the function inscribes the circle within the boundary rings, treating internal rings as additional constraints. When processing linear and point inputs, the algorithm inscribes the circle within the convex hull of the input, utilizing the input lines and points as additional boundary constraints.
Formats:
ST_MaximumInscribedCircle(geometry: Geometry)ST_MaximumInscribedCircle(geometry: Geometry, tolerance: Double)
The optional tolerance controls when the circle-center search stops
refining. A value of 0 uses the geometry-dependent default
max(width, height) / 1000, which is also used by the one-argument form.
The tolerance must otherwise be positive.
The two-argument overload was added in v1.9.1.
Return type: Struct<center: Geometry, nearest: Geometry, radius: Double>
Since: v1.6.1
SQL Example:
SELECT inscribedCircle.* FROM (
SELECT ST_MaximumIncribedCircle(ST_GeomFromWKT('POLYGON ((62.11 19.68, 60.79 17.20, 61.30 15.96, 62.11 16.08, 65.93 16.95, 66.20 20.61, 63.08 21.43, 64.48 18.70, 62.11 19.68))')) AS inscribedCircle
)
Output:
+---------------------------------------------+-------------------------------------------+------------------+
|center |nearest |radius |
+---------------------------------------------+-------------------------------------------+------------------+
|POINT (62.794975585937514 17.774780273437496)|POINT (63.36773534817729 19.15992378007859)|1.4988916836219184|
+---------------------------------------------+-------------------------------------------+------------------+