#!/usr/local/bin/perl $com="dir input\\*.hdf /B /O:N >dir.txt"; system($com); $com="md output"; system($com); $com="md mosaic"; system($com); open (DRL, "dir.txt"); open(OUT, ">batch.bat"); print OUT "set MRTDATADIR=C:\\Modis\\\n"; my @allmodis=; $num=@allmodis; $num1=$num/6; $inc=0; while ($inc < $num1) { open(TMP, ">mod$inc.txt"); open(PRM, ">mod$inc.prm"); $inc1=0; while ($inc1 < 6) { $numline=$inc*6+$inc1; $line = @allmodis[$numline]; $line =~ s/\n//; ($temp1,$temp2,$temp3,$temp4,$temp5,$temp6)=split('\.',$line); $newfile="MODA_1km_250_05_NDVI\_$temp2.hdf"; $mosfile="mos\_$temp2.hdf"; print TMP "C:\\modwork\\input\\$line\n"; ++$inc1; } close (TMP); print PRM "INPUT_FILENAME = C:\\modwork\\mosaic\\$mosfile\n"; print PRM "SPECTRAL_SUBSET = ( 1 )\n"; print PRM "SPATIAL_SUBSET_TYPE = INPUT_LAT_LONG\n"; print PRM "OUTPUT_FILENAME = C:\\modwork\\output\\$newfile\n"; print PRM "RESAMPLING_TYPE = NEAREST_NEIGHBOR\n"; print PRM "OUTPUT_PROJECTION_TYPE = LA\n"; print PRM "OUTPUT_PROJECTION_PARAMETERS = ( \n"; print PRM " 6370997.0 0.0 0.0\n"; print PRM " 0.0 -100.0 45.0\n"; print PRM " 0.0 0.0 0.0\n"; print PRM " 0.0 0.0 0.0\n"; print PRM " 0.0 0.0 0.0 )\n"; print PRM "DATUM = NoDatum\n"; print PRM "OUTPUT_PIXEL_SIZE = 1000\n"; close (PRM); print OUT "C:\\Modis\\bin\\mrtmosaic -i C:\\modwork\\mod$inc.txt -o C:\\modwork\\mosaic\\mos\_$temp2.hdf -s 1 0 0 0 0 0 0 0 0 0 0\n"; print OUT "C:\\Modis\\bin\\resample -p C:\\modwork\\mod$inc.prm\n"; ++$inc; } close (OUT); close (DRL); $com="del *.txt\n"; system($com);