shapely.maximum_inscribed_circle

shapely.maximum_inscribed_circle#

maximum_inscribed_circle(geometry, tolerance=None, **kwargs)#

Find the largest circle that is fully contained within the input geometry.

Constructs the “maximum inscribed circle” (MIC) for a polygonal geometry, up to a specified tolerance. The MIC is determined by a point in the interior of the area which has the farthest distance from the area boundary, along with a boundary point at that distance. In the context of geography the center of the MIC is known as the “pole of inaccessibility”. A cartographic use case is to determine a suitable point to place a map label within a polygon. The radius length of the MIC is a measure of how “narrow” a polygon is. It is the distance at which the negative buffer becomes empty.

The function supports polygons with holes and multipolygons.

Returns a two-point linestring, with the first point at the center of the inscribed circle and the second on the boundary of the inscribed circle.

Added in version 2.1.0.

Parameters:
geometryGeometry or array_like
tolerancefloat or array_like, optional

Stop the algorithm when the search area is smaller than this tolerance. When not specified, uses max(width, height) / 1000 per geometry as the default.

**kwargs

For other keyword-only arguments, see the NumPy ufunc docs.

Examples

>>> import shapely
>>> from shapely import Polygon
>>> poly = Polygon([(0, 0), (0, 10), (10, 10), (10, 0), (0, 0)])
>>> shapely.maximum_inscribed_circle(poly)
<LINESTRING (5 5, 0 5)>