ArcGIS Batch Processing – Batch Processing 400 MODIS HDF4 Files Using Several Tools in ArcGIS 10

arcgis-10.0batchmodelbuildermodispython

This is my first post, I hope I don't screw it up. We have about 400 MODIS HDF4 files we are looking to batch process in the ArcGIS 10 or Python environment. The tools we are looking to use are Extract Subdataset (HDF4 files have subdatasets and we are only interested in one of them, which its index number is 1), ProjectRaster(to UTM 11 NAD 83), convert HDF4 files to TIFF (although I believe this can be done when executing the Extract Subdataset tool as it lets you choose an output file format), Int (we need the raster file to have an attribute table with pixel values). I've tried performing these tasks in modelbuilder in batch mode but i've had no success in properly setting it up.

We are interested in both the ModelBuilder and Python approach.

It would be great if someone can post some batch processing code that would apply to these tools.

Best Answer

I routinely do this with GDAL and a simple bash script. You can also do ith with python, but I think this is quite straightforward and easier to understand

#!/bin/bash

# This script reprojects and subsets a bunch of HDF files stored in
# a given dir (WORKDIR). The output is a GeoTIFF formatted file.
#

WORKDIR="./" # Where all HDF files are stored
TARGET_SRS="EPSG:2153" # Your projection. See spatialreference.org
TARGET_EXTENT="0 0 10 10" # The target's extent (xmin ymin xmax ymax)
                          # In target units!
TARGET_RES="1000" # Whatever you want the output resolution to be
for granule in ${WORKDIR}/*.hdf
do
    output_name=`basename $granule .hdf`.tif
    gdalwarp -t_srs ${TARGET_SRS} -te ${TARGET_EXTENT} -tr ${TARGET_RES}\
             -of GTiff -co "COMPRESS=LZW" \
             'HDF4_EOS:EOS_GRID:"'${granule}'":MOD_Grid_MOD15A2:Fpar_1km' \
             ${output_name}
done

This is an example for the fAPAR layer in the MOD15 product, so you'd have to modify that particular line for whatever it is that you want.

Related Question