Returns the bounding box of a raster as a PostgreSQL BOX value in ((maxX,maxY),(minX,minY)) format.
Syntax
BOX ST_Extent(raster raster_obj, CoorSpatialOption csOption = 'WorldFirst')
BOX ST_Extent(raster raster_obj, integer pyramid, CoorSpatialOption csOption = 'WorldFirst')Parameters
| Parameter | Description |
|---|---|
raster_obj | The raster object to query. |
pyramid | The pyramid level to query. Valid values start from 0. |
csOption | The coordinate space to use. Default: WorldFirst. |
Description
ST_Extent returns a BOX value representing the bounding box of the raster. The format is ((maxX,maxY),(minX,minY)) — the upper-right corner appears first, followed by the lower-left corner.
The csOption parameter controls which coordinate space is used:
| Value | Behavior |
|---|---|
Raster | Returns pixel coordinates. |
World | Returns world (geographic) coordinates. |
WorldFirst | Returns world coordinates if the raster is georeferenced; otherwise returns pixel coordinates. |
Note
WorldFirst is the default. If the raster is not georeferenced and you call ST_Extent without specifying csOption, the result is in pixel coordinates. To always get world coordinates, pass 'World'::CoorSpatialOption explicitly.
Examples
Return pixel coordinates:
SELECT ST_Extent(raster_obj, 'Raster'::CoorSpatialOption) FROM raster_table;Result:
((255,255),(0,0))Return world coordinates:
SELECT ST_Extent(raster_obj, 'World'::CoorSpatialOption) FROM raster_table;Return world coordinates at a specific pyramid level:
SELECT ST_Extent(raster_obj, 2, 'World'::CoorSpatialOption) FROM raster_table;