1

I'm using gdalwarp to convert a large numbers MODIS Swath (MOD11, MOD06, MOD07) products to TIF and need to mosaic the output images with same day of year.

There is a example of output data:

MOD11_L2.A2014001.1300.006.2016179212636.tif MOD11_L2.A2014001.1305.006.2016179220648.tif MOD11_L2.A2014002.1205.006.2016179200050.tif MOD11_L2.A2014002.1210.006.2016179203811.tif MOD11_L2.A2014002.1345.006.2016179203914.tif MOD11_L2.A2014002.1350.006.2016179203951.tif MOD11_L2.A2014003.1250.006.2016180000700.tif MOD11_L2.A2014003.1255.006.2016180000720.tif etc.

The images have 1, 2, 3 or 4 archives. I'm trying to use the following script without sucess:

    #!/bin/bash
    echo '==> Mosaic of MODIS Images'
    g = 001
    for f in *.tif
    do
      echo "==> Processing $f";
      gdalbuildvrt ${f/.tif/.vrt} "*A2014"+$g+"*.tif"
      gdalwarp -overwrite -of GTIFF -tps ${f/.tif/.vrt} Mosaic_${f/.tif/.vrt}.tif
      g = g+1
    done
    echo '==> Script finished with sucess'
    #done
0

I found the solution on another post showing how to batch the mosaic process with a python code:

    #!/usr/bin/env python
    #coding: utf-8
    from osgeo import gdal
    import glob
    for day in range(0, 32):
    day = str('%0.3d' % day)
    gdal.BuildVRT("MOD11_L2.A2014"+day+"_LST.vrt", glob.glob("MOD11_L2.A2014"+day+"*.tif"))

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.