2

I need to produce a Landsat mosaic over part of Indonesia and an extra shapefile containing the dates of each part of the mosaic.

The steps I used are:

  1. Stack 3 bands to produce RGB image
  2. Project images into WGS84 (gdalwarp)
  3. Build a virtual stack (mosaic, in this case) using gdalbuildvrt.

How can I produce polygons shapefile that contains the the footprint of each Landsat image within the mosaic (hence the date)?

4

Use gdal_polygonize.py, ogr2ogr and ogrinfo in a loop. On linux (not tested):

final=merged.shp
for f in *.tif;
do
    name=$(basename $f .tif)
    shp=${name}.shp
    gdal_polygonize.py $f -f "ESRI Shapefile" $shp
    ogrinfo $shp -sql "ALTER TABLE $name ADD COLUMN name character(30)"
    ogrinfo $shp -sql "UPDATE $name SET name='$name'"
    if [ -f $final ];
    then
        ogr2ogr -f "ESRI Shapefile" -update -append $final $shp -nln merge
    else
        ogr2ogr -f "ESRI Shapefile" $final $shp
    fi
done

The two calls to ogrinfo create and then populate a field called "name" on each new shapefile. When the ogr2ogr calls merge the files, each geometry will have a field indicating what the name of the original image was. Of course, you can extract the date from the name and save that, if you like.

The if statement checks if the merged file exists. If not, it creates it from the first shapefile. Otherwise it appends the shapefile.

0

The simplest tool you can use is gdaltindex in gdal for creating a shape file for all the landset images in one go.

For more information refer gdaltindex

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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