shapely.oriented_envelope#

oriented_envelope(geometry, **kwargs)#

Computes the oriented envelope (minimum rotated rectangle) that encloses an input geometry.

Note

‘oriented_envelope’ requires at least GEOS 3.6.0.

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

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

Examples

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