Returns the bounding box of a raster as a PostgreSQL BOX value in ((maxX,maxY),(minX,minY)) format, where (maxX,maxY) is the upper-right corner and (minX,minY) is the lower-left corner.
Syntax
BOX ST_Extent(raster raster_obj, CoorSpatialOption csOption = 'WorldFirst')
BOX ST_Extent(raster raster_obj, integer pyramid, CoorSpatialOption csOption = 'WorldFirst')Parameters
| Parameter | Type | Description |
|---|---|---|
raster_obj | raster | The raster whose bounding box you want to get. |
pyramid | integer | The pyramid level to query. Valid values start from 0. |
csOption | CoorSpatialOption | The coordinate space for the returned bounding box. Default: WorldFirst. |
csOption values
| Value | Behavior |
|---|---|
Raster | Returns pixel coordinates. |
World | Returns world coordinates. |
WorldFirst | Returns world coordinates if the raster is georeferenced; otherwise returns pixel coordinates. |
Examples
The following examples demonstrate each csOption value.
Pixel coordinates — use Raster to get pixel-space bounds:
SELECT ST_Extent(raster_obj, 'Raster'::CoorSpatialOption) FROM raster_table;Output (pixel coordinates for a 256x256 raster):
((255, 255), (0, 0))World coordinates — use World or WorldFirst to get geographic bounds when the raster is georeferenced:
SELECT ST_Extent(raster_obj, 'World'::CoorSpatialOption) FROM raster_table;
SELECT ST_Extent(raster_obj, 'WorldFirst'::CoorSpatialOption) FROM raster_table;Query at a specific pyramid level — pass the pyramid level as the second argument:
SELECT ST_Extent(raster_obj, 2, 'WorldFirst'::CoorSpatialOption) FROM raster_table;What's next
ST_ConvexHull: Get the convex hull geometry of a raster.
ST_MetaData: Get metadata including the spatial reference and pixel dimensions of a raster.
ST_TopPyramidLevel: Get the highest pyramid level available for a raster.