Calculating Image boundary / footprint of satellite images using open source tools?

I finally found a way to do this:

step 1: gdalwarp -dstnodata 0 -dstalpha -of GTiff foo1 foo2

This does two important things: it sets the destination No Data (outside border) values to 0, and it creates an alpha band.

step 2: gdal_polygonize.py foo2 -b 2 -f "ESRI Shapefile" foo3

The second step uses the alpha band (band 2), created in step 1, and creates a shapefile from that band.

This can then easily be scripted in a bash script, if you have many images, to create exact outlines for.  


Image Boundary plugin did not work for me either, therefore I used the same approach with GDAL. Nevertheless it only worked for me after changing the first step to:

step 1: gdalwarp -srcnodata 0 -dstalpha -of GTiff foo1 foo2

I am working with Landsat8 band (where no data=0) and when using the -dstnodata function I get:

band1 with no data = 'no data'
band2 (Alpha band) = '255' for the entire scene/extent

whereas with -srcnodatafunction I get:

band1 with no data = 'no data'
band2 (alpha band) with no data = 'no data' and valid data = '255' which then allows to extract polygon for valid data only.

I couldn't fully understand the reason behind this behavior (how alpha is computed?) , but I hope this might help others facing the same problem.


I used gdal_translate as suggested by the GDAL project.

gdal_translate -b mask -of vrt -a_nodata 0 test.tif test.vrt
# Note the  -a_nodata 0 doesn't seem to work when the mask is input, so do another pass
gdal_translate -b 1 -of vrt -a_nodata 0 test.vrt test2.vrt
gdal_polygonize.py -q  -8 test2.vrt -b 1 -f "ESRI Shapefile" testdata.shp

enter image description here