> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ST_MinimumWidthRectangle

Returns the minimum-width rotated rectangle enclosing a geometry. Unlike `ST_OrientedEnvelope`, which minimizes the area of the enclosing rectangle, this function minimizes the width (shortest side). The result may differ from `ST_OrientedEnvelope` for geometries where the minimum-area and minimum-width orientations diverge (see example below). Degenerate inputs may result in a Point or LineString being returned.

<img src="https://mintcdn.com/wherobots/wLm_IRUSNlHZTHJP/images/sql-functions/ST_MinimumWidthRectangle/ST_MinimumWidthRectangle.svg?fit=max&auto=format&n=wLm_IRUSNlHZTHJP&q=85&s=6fde5bf8b7cebe85d4f190f70f60de09" alt="ST_MinimumWidthRectangle" width="500" height="300" data-path="images/sql-functions/ST_MinimumWidthRectangle/ST_MinimumWidthRectangle.svg" />

## Signatures

```sql theme={"system"}
ST_MinimumWidthRectangle(geom: Geometry)
```

## Parameters

<ParamField body="geom" type="Geometry" required>
  The input geometry.
</ParamField>

## Return type

<ResponseField type="Geometry">
  The resulting geometry.
</ResponseField>

## Examples

For a right triangle, `ST_MinimumWidthRectangle` tilts the rectangle along the hypotenuse to minimize the width, while `ST_OrientedEnvelope` keeps it axis-aligned to minimize area:

```sql theme={"system"}
SELECT ST_MinimumWidthRectangle(ST_GeomFromWKT('POLYGON ((0 0, 5 0, 0 3, 0 0))'))
```

```
POLYGON ((5 0, 3.68 -2.21, -1.32 0.79, 0 3, 5 0))
```

Compare with `ST_OrientedEnvelope` on the same input:

```sql theme={"system"}
SELECT ST_OrientedEnvelope(ST_GeomFromWKT('POLYGON ((0 0, 5 0, 0 3, 0 0))'))
```

```
POLYGON ((0 3, 5 3, 5 0, 0 0, 0 3))
```
