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.

2 Answers 2


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.

  • This gives me just a rectangular envelope (bounding box). I'm looking for a polygon which describes the data area of the raster. With satellite pictures the resulting polygon will be a trapezoidal shape in most cases.
    – ABX
    Sep 11, 2013 at 7:52
  • 1
    The shape can be projection-dependent. Why don't you try ST_PixelAsPolygon followed by ST_ConvexHull?
    – Arthur
    Sep 11, 2013 at 17:55

Please take a look at ST_DumpAsPolygons. It will draw the polygons around your raster shapes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.