3

I have monthly MODIS images for 2001-2014. For few images mosaicing with reprojection can be done using MRT tool. However, for large number of images it's a cumbersome process.

There are multiple folder in a pattern, where each image is saved in a particular folder (representing MONTH) and all the months of a particular year are stored in a specific folder named after corresponding YEAR. Below is the example for reference

MODIS\Y2000\M01
Image#1
Image#2
...

MODIS\Y2000\M02
Image#1
Image#2
...
...
...
...
...

MODIS\Y2014\M12
Image#1
Image#2
...

Is there any way out to automate this process using MRT tool?

1

I use cygwin Linux shell under Windows OS. You should install Cygwin firstly. Then create MRT .prm file of single stage (this you have done for fewer images) by using MRT tool. enter image description here

Put this .prm file with all modis tiles under same folder such as test. Open .prm with txt and you could modify some parameters.

#INPUT_FILENAMES = ( D:\2000\049\MOD09A1.A2000049.h23v04.005.2006268204857.hdf D:\2000\049\MOD09A1.A2000049.h23v05.005.2006268204906.hdf D:\2000\049\MOD09A1.A2000049.h24v04.005.2006268205301.hdf D:\2000\049\MOD09A1.A2000049.h25v05.005.2006268195439.hdf D:\2000\049\MOD09A1.A2000049.h25v06.005.2006268195239.hdf D:\2000\049\MOD09A1.A2000049.h26v05.005.2006268195515.hdf D:\2000\049\MOD09A1.A2000049.h26v06.005.2006268195738.hdf D:\2000\049\MOD09A1.A2000049.h27v06.005.2006268195209.hdf D:\2000\049\MOD09A1.A2000049.h28v05.005.2006268195532.hdf D:\2000\049\MOD09A1.A2000049.h28v06.005.2006268195152.hdf D:\2000\049\MOD09A1.A2000049.h28v07.005.2006268195415.hdf D:\2000\049\MOD09A1.A2000049.h29v06.005.2006268195305.hdf )

INPUT_FILENAME = D:\TmpMosaic.hdf

SPECTRAL_SUBSET = ( 1 1 )
#ORIG_SPECTRAL_SUBSET = ( 1 1 0 0 0 0 0 0 0 0 0 0 0 )

SPATIAL_SUBSET_TYPE = INPUT_LAT_LONG

SPATIAL_SUBSET_UL_CORNER = ( 49.999999996 77.786191329 )
SPATIAL_SUBSET_LR_CORNER = ( 9.999999999 121.851193415 )

OUTPUT_FILENAME = D:\m2000049.tif

RESAMPLING_TYPE = NEAREST_NEIGHBOR

OUTPUT_PROJECTION_TYPE = GEO

OUTPUT_PROJECTION_PARAMETERS = ( 
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0
0.0 0.0 0.0 )

DATUM = NoDatum

OUTPUT_PIXEL_SIZE = 0.009

last, open cygwin shell and cd to the modis tiles folder.

cd  E:/modis/change/MOD09Q1/test

use codes as follow:

day=2000049      #start time 
while [ $day -le 2000081 ]   #end time serial   
do
for trl in MOD09Q1.A$day.*.hdf      # modis image file names 
do
if [ -f $trl ]
then
HDFFILES=$(ls MOD09Q1.A$day.*.hdf)
echo $HDFFILES > MOSAICINPUT.TXT
MRTMOSAIC -i MOSAICINPUT.TXT -s "1 0 0" -o MOSAIC_TMP_$day.hdf
RESAMPLE -p MOD09Q1.PRM -i MOSAIC_TMP_$day.hdf -o MOD09Q1_$day.tif

#MOD09Q1.PRM  the .prm file have saved before

let "day=day+8"    # the modis image time interval such as 8day,16day...

break
else
let "day=day+8"
break
fi

done
done

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.