shapely.minimum_rotated_rectangle

shapely.minimum_rotated_rectangle#

minimum_rotated_rectangle(geometry, **kwargs)#

Computes the oriented envelope (minimum rotated rectangle) that encloses an input geometry, such that the resulting rectangle has minimum area.

Unlike envelope this rectangle is not constrained to be parallel to the coordinate axes. If the convex hull of the object is a degenerate (line or point) this degenerate is returned.

Parameters:
geometryGeometry or array_like
**kwargs

See NumPy ufunc docs for other keyword arguments.

Examples

>>> from shapely import GeometryCollection, LineString, MultiPoint, Point, Polygon
>>> oriented_envelope(MultiPoint([(0, 0), (10, 0), (10, 10)])).normalize()
<POLYGON ((0 0, 10 10, 15 5, 5 -5, 0 0))>
>>> oriented_envelope(LineString([(1, 1), (5, 1), (10, 10)])).normalize()
<POLYGON ((1 1, 10 10, 12 8, 3 -1, 1 1))>
>>> oriented_envelope(Polygon([(1, 1), (15, 1), (5, 10), (1, 1)])).normalize()
<POLYGON ((1 1, 1 10, 15 10, 15 1, 1 1))>
>>> oriented_envelope(LineString([(1, 1), (10, 1)])).normalize()
<LINESTRING (1 1, 10 1)>
>>> oriented_envelope(Point(2, 2))
<POINT (2 2)>
>>> oriented_envelope(GeometryCollection([]))
<POLYGON EMPTY>