Quantcast
Viewing latest article 6
Browse Latest Browse All 14

Using gdal_merge to merge a large amount of files (in pairs)

I’m new to python and how it can be applied to gis.
I have a large amount of MODIS files to go through and I’ve already extracted, reprojected and converted to GTiff the bands that I need from each HDF file using convertModisGDAL from pymodis.

Now I need to mosaic pairs of this file list. More specifically, I have this kind of files and I need to merge the h24′s with the h25′s:

MOD11A2.A2000065.h24v04.005.2007176173328_LST_Day_1km.tiff
MOD11A2.A2000065.h25v04.005.2007176173328_LST_Day_1km.tiff

MOD11A2.A2000065.h24v04.005.2007176173328_QC_Day.tiff
MOD11A2.A2000065.h25v04.005.2007176173328_QC_Day.tiff

Do you have any suggestions on how can I accomplish this with gdal_merge?

I was trying to do so something with this but I have not been very successful:

for root, dirs, files in os.walk(inputFolder):

    for hdf24 in fnmatch.filter(files,pattern_24):
        p1 = os.path.realpath(os.path.join(root,hdf24))

        for hdf25 in fnmatch.filter(files,pattern_25):
            p2 = os.path.realpath(os.path.join(root,hdf25))

            sys.argv = ['-o','outputTif12','-of','GTiff','-ot','Float64','-n','0','-a_nodata', '-9999', p1, p2]
            gdal_merge.main()

Thank you


Viewing latest article 6
Browse Latest Browse All 14

Trending Articles