Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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".

share|improve this question
What version of ArcMap are you using? –  Paul Jun 28 '13 at 14:44
It looks like you are attempting to do this: forums.arcgis.com/threads/64824-Two-iterators-in-modelbuilder –  Nick Ochoski Jun 28 '13 at 15:39

1 Answer 1

up vote 0 down vote accepted

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:

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.

share|improve this answer
I'm not exactly sure what you are asking. Each file is for wind speeds in the meridional and zonal directions. so the in the raster calculator I have to use the con function so if the values of each cell in both rasters is one thing then I need the output raster to be something using a calculation. I can do all this individually, but I have 24 files for each meridional and zonal for 5 days. so it would be easier to use model builder and do a batch. I can give you an example of the con function I will be using if that will help. Also, I am using ArcMap 10.1. –  Katelyn Jun 28 '13 at 14:48
I'm not sure entirely what you are asking for. You need the con function to point to a raster layer or a text file containing constants? Both can be used as inputs for the con function. And yes, please edit your opening post with any information you think we might find useful. –  Paul Jun 28 '13 at 15:06
Please see edits. Maybe that last part will explain what I am trying to do. I need the output to be a single raster file. What I am doing is actually calculating wind direction from the meridional and zonal files. –  Katelyn Jun 28 '13 at 15:18
I hope I have the gist of it. –  Paul Jun 28 '13 at 15:48
Thanks! that helps a lot, I will give it a try. –  Katelyn Jun 28 '13 at 15:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.