3

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.

Vince
  • 20,017
  • 15
  • 45
  • 64
ABX
  • 737
  • 12
  • 28

2 Answers2

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.

Arthur
  • 2,292
  • 1
  • 17
  • 27
  • 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 '13 at 07:52
  • 1
    The shape can be projection-dependent. Why don't you try ST_PixelAsPolygon followed by ST_ConvexHull? – Arthur Sep 11 '13 at 17:55
0

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

Tommie Jones
  • 319
  • 1
  • 9