> ## 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_GeomFromBox2D

Converts a `Box2D` to a closed rectangular polygon `Geometry`. Equivalent to PostGIS `box2d::geometry`. Degenerate boxes return the appropriate lower-dimensional geometry:

| Box2D shape                                          | Returned geometry                         |
| :--------------------------------------------------- | :---------------------------------------- |
| Both axes have non-zero extent                       | `POLYGON` (closed rectangle)              |
| One axis collapsed (e.g. `xmin == xmax`)             | `LINESTRING` along the non-collapsed axis |
| Both axes collapsed (`xmin == xmax && ymin == ymax`) | `POINT`                                   |

It is also produced by the SQL cast `CAST(box AS geometry)`.

Returns `NULL` on `NULL` input.

## Signatures

```sql theme={"system"}
ST_GeomFromBox2D(box: Box2D)
```

## Parameters

<ParamField body="box" type="Box2D" required>
  The bounding box to convert to a geometry.
</ParamField>

## Return type

<ResponseField type="Geometry">
  A closed rectangular polygon (or a lower-dimensional geometry for degenerate boxes).
</ResponseField>

## Example

```sql theme={"system"}
SELECT ST_AsText(ST_GeomFromBox2D(ST_MakeBox2D(ST_Point(0.0, 0.0), ST_Point(2.0, 4.0))))
```

```
POLYGON ((0 0, 0 4, 2 4, 2 0, 0 0))
```
