rmosaichdf

How to mosaic the same HDF files using this R function?


There are more than 1,000 MODIS HDF images in a folder:

M:\join

Their names show us which files must be mosaiced together.

For example, in the below files, 2009090 means these three images must be mosaiced together:

MOD05_L2.A2009090.0420.051.2010336084010
MOD05_L2.A2009090.0555.051.2010336100338
MOD05_L2.A2009090.0600.051.2010336100514

Or these two, are for the same date, 2009091:

MOD05_L2.A2009091.0555.051.2010336162871
MOD05_L2.A2009091.0600.051.2010336842395

I am going to mosaic them using this function (source of function ):

mosaicHDF(hdfNames, filename, MRTpath, bands_subset, delete=FALSE)

How should I introduce my HDF files to hdfNames?

And what should I write in filename?

I tried to find a manual for this function, but there was not anything.

Thanks for your help.


Solution

  • I did find the answer, fortunately. Thanks for your help.

    hdfs <- c('MOD05_L2.A2009090.0420.051.2010336084010.hdf',
              'MOD05_L2.A2009090.0555.051.2010336100338.hdf',
              'MOD05_L2.A2009090.0600.051.2010336100514.hdf')
    
    mosaicHDF(hdfNames=hdfs, filename='newhdf.hdf', MRTpath='C:/MRT/bin',bands_subset="1 0 0 0", delete=FALSE) 
    

    But I have a new problem :-)

    Since there are thousands of HDF files in the folder,

    How could I write a loop to introduce all HDF files to the function?

    FYI: I am quite new to R.