[GIS] Raster Calculator in Model Builder

arcgis-10.1batchmodelbuilderraster-calculator

I am trying to calculate a con function for a couple hundred rasters (Meridional and Zonal raster data for wind, each being their own raster file). Is there a way to use model builder with the raster calculator and do a loop to go through all the files? I know I need to start off with the iterate raster input; but am lost after that. Also, the files are different: Zonal_04_01_2011_0000 and Meridional_04_01_2011_0000 (for each hour through 2300). each con function uses the zonal and meridional files. If there is a way to do a batch in model builder, when the function continues onto the next files, will it automatically use the files for the 0100 hour meridional and zonal? I hope all this makes sense. I have also looked up ways to do this and a lot of them use python, however, I do not know any python. So if there is a way to compute this without python, that would be great.

using this con function within rater calculator:

Con(("Zonal_4_01_2011_0000.tif" < 0) & ("Meridional_4_01_2011_0000.tif" >= 0), 180- ((ATan(("Meridional_4_01_2011_0000.tif")/("Zonal_4_01_2011_0000.tif"))*57.296), Con(bla bla bla with the same files))

The last four digits in the files are the hour: 0000 is midnight and the files go to 2300 hours.

I need the model builder to go through each of the hours and output a raster file. So after the function goes through the "Zonal_4_01_2011_0000.tif" and "Meridional_4_01_2011_0000.tif" files, the next ones to be used at the same time are "Zonal_4_01_2011_0100.tif" and "Meridional_4_01_2011_0000.tif".

Best Answer

I think I understand what you are trying to do now. You need to loop over all the meridional and zonal (24 each) TIFFs and use these as inputs for each raster in your directory.

If that is the case, then you need to nest iterators. The first one will loop over the raw images while the second loops over each M&Z file, passing this as input to the con function. You'll need an in-line variable to do that. The variable is the name of each M&Z file (which changes each loop).

If you want to loop over rasters in a directory, you need to use an iterator. You can run the model on all the rasters (restricted by image type if desired).

In simple, rough pseudo code, I would imagine it would look something like this:

rawpath = "directory containing raw images"
MZpath = "directory containing M&Z files"
for each raster in rawpath:
    for each MZ in MZpath:
       Con(raster,M,Z)
       Con.save()

Edit: Apparently you can only have one iterator in modelbuilder. That's immensely annoying. As @Radar pointed out, you could nest models together. What I would do is get your model to work on just 1 image (using all the M&Z) files and then try to nest it within another model. Or learn Python, where this task would be very simple.

Related Question