ST_OrientedEnvelope

更新时间:
复制 MD 格式

Returns the minimum-area rotated rectangle that encloses a geometry object.

Unlike ST_Envelope, which produces an axis-aligned bounding box, ST_OrientedEnvelope rotates the rectangle to find the tightest fit for the input geometry.

Syntax

geometry ST_OrientedEnvelope(geometry geom);

Parameters

ParameterDescription
geomThe geometry object to compute the oriented envelope for.

Usage notes

  • The minimum-area rotated rectangle is not always unique. If multiple rectangles with equal minimum area exist, the function returns one of them.

  • For degenerate input — such as a single point or a set of collinear points — the function may return a Point or LineString instead of a Polygon.

Examples

Polygon input

The following query returns the oriented envelope of a Polygon and compares it with the original geometry:

SELECT ST_OrientedEnvelope(g), g
FROM (
  SELECT 'POLYGON((0 0,1 0,1 1,0 1,0 0),(3 3,4 3,4 4,3 4,3 3))'::geometry AS g
) AS t;
1

See also

FunctionDescription
ST_EnvelopeReturns an axis-aligned bounding box. Use this when the rectangle must be aligned to the coordinate axes.
ST_MinimumBoundingCircleReturns the smallest circle that encloses the geometry. Use this when a circular boundary is needed.