[GIS] How to create an outline polygon (footprint) from raster data with PostGIS

footprintpolygonpostgisraster

How can I create a polygon, containing the actual outlines (aka footprint) of a raster file with PostGIS?

I just need the outlines of the data containing parts of the raster.

ST_PixelAsPolygon creates a complex polygons – but I just need the footprint.

There is a similar question here Creating shapefile showing footprints of Rasters?, but the answers do not cover PostGIS.

Best Answer

Use the ST_Envelope function:

SELECT ST_Envelope(rast)
  FROM raster_table;

This will return a rectangular bounding box for your raster(s). PostGIS describes what this function returns as:

Returns the polygon representation of the extent of the raster.

Related Question