Returns the bounding box of a raster as a geometry object.
Syntax
geometry ST_Envelope(raster source);
geometry ST_Envelope(raster source, integer pyramid);Parameters
| Parameter | Description |
|---|---|
| source | The raster whose bounding box you want to obtain. |
| pyramid | The pyramid level of the raster. Valid values start from 0. Default value: 0. |
Description
ST_Envelope returns the minimum bounding rectangle of a raster as a polygon geometry. You can use the pyramid parameter to obtain the bounding box at a specific pyramid level.

Examples
Get the bounding box of a raster at the default pyramid level (0):
SELECT st_astext(st_envelope(rast_object))
FROM raster_table;
----------------------------------------------------
POLYGON((-180 90,180 90,180 -90,-180 -90,-180 90))Get the bounding box at pyramid level 1:
SELECT st_astext(st_envelope(rast_object, 1))
FROM raster_table;
----------------------------------------------------
POLYGON((-180 90,180 90,180 -90,-180 -90,-180 90))