Wednesday 19 September 2018

python - Batch Processing 400 MODIS HDF4 Files Using Several Tools In ArcGIS 10


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.



Answer



Sounds do-able. I would suggest looking at the docs, specifically the sections on listing data and the tools you need to use, such as the Extract Subdataset tool - there are lots of samples in both of those sections to get you going. If I understand the issue properly, you need to get a list of the rasters, then iterate through that list, processing as you go: Extract Subdataset (save as tiff) -> Project -> Convert to int (you could use Map Algebra to do that).


EDIT: To change the filename, use some slicing to get only the name without the extension:


arcpy.ExtractSubDataset_management(hdf,"U:\\temp\\hdf\\subdataset_files\\" + hdf[:4] + ".tif", "0")

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...