Iterate Raster Collect Values Sub-Model Batch process question.

2999
6
01-07-2011 08:43 AM
DavidQuillin
New Contributor
Using the desktop help ("Examples of using Model Only tools in ModelBuilder"), I replicated the model example that was provided for Collect Values. It iterates through rasters in a workspace, collects the values, then passes those values to the Mosaic to New Raster tool. This works fine when I provide one workspace but if I try to batch process multiple workspaces (I've got thousands of them) the resulting mosaic output is wrong.
What seems to happen is it only collects the first raster in the first workspace provided, then it moves to the next workspace, iterates / collects all of those rasters, then passes all this to the Mosaic to New Raster tool. The output is a mosaic raster containing inputs from multiple workspaces. This is wrong in two ways: 1) Each workspace needs to be operated on separately and 2) not all rasters are being collected in the iteration process. 
So am I missing something here? Is it even possible to batch process a model iteration?

Thanks in advance for any input provided.

Dave
0 Kudos
6 Replies
paulcripps
New Contributor
It does exhibit some strange behaviour. I'm using the modelbuilder to automate (as per example given, using iterate rasters then collect values to gather rasters) and on iterating through a folder containing rasters, it passes each one in turn, then reiterates, rather than iterating through the lot then passing the whole collection to the mosaic function. eg:

rast1
mosaic

rast1
rast2
mosaic

rast1
rast2
rast3
mosaic

...

rast1
rast2
rast3
rast4
rast5
...
rastN
mosaic


Now as i'm using the max operator, this does not affect output, simply makes the process incredibly slow. Especially when i have >100 rasters in each folder! I've checked output (against a manual mosaic) and it is including all the rasters, not missing any as some other people on other threads have found.

I have lots of folders so the point was to automate going through the set of folders, each containing many rasters.

I tried to batch the model and rather than mosaicing each set from each folder to a separate output, it mosaics them all together, rather than keeping each run of the model separate.

I tried to nest the model inside another model which iterated the folders containing each set of rasters and it fails (number of bands must match error) despite the child model working fine on it's own. The only thing being passed in being the input folder containing each set of rasters.

Am now doing each workspace individually. Thankfully not too many but still painful, especially having lost time to trying to get models to work...
0 Kudos
ShitijMehta
Esri Regular Contributor
Hi Paul_c,

It is always recommended that you should not mix bath and iteration together as both have different ways of execution.

Meanwhile share a snapshot of your models and the data structure you are using. It might help in suggesting a solution.

Also, check this post to understand nested models a bit more and look at the image attached to the entry on 09-26-2011 02:07 PM. May be this helps.

To iterate through all the folders put all the folders in one main root folder and check the recursive option in the iterate raster iterator.

For the Mosaic to Raster tool the help says "The inputs must have the same number of bands and same bit depth; otherwise, the tool will exit with an error message."
0 Kudos
tuango
by
New Contributor
Hi,

Thanks very much for this comment. It help me to think about my ideals.

Tks again and pls keep posting.
0 Kudos
tuango
by
New Contributor
Thanks for your link. It's useful for our community.
Same material can be found at : MOSAIC model
I hope it's useful for you and you like it. Please continue sharing more information at this topic.
Best rgs!
0 Kudos
ZackSteel
New Contributor
Hi, I am having a similar problem with combining an iterator and the collect values tool with the Mosaic to New Raster tool. Basically I would like to collect a number of rasters from a geodatabase based on a Wildcard specification, then mosaic these into a new raster. However, I continue to get the ERROR 00157 "Input and target dataset should have the same number of bands". I'm not sure what the problem is. All the rasters have a single band and I am following almost the exact same process as ESRI's example of how to use the Collect Values tool. I have also attached an image of what my model looks like.
Thank you for the help.
0 Kudos
DavidHockman-Wert
New Contributor II
Zack, this may or may not work, but one thing I have been learning about Collect Values is that it runs best when run in a sub-model, and the "collected" values are passed back into a main model all at once.  Otherwise, one experiences what paul_c describes, where the Mosaic tool runs after each iteration.  One of ESRI's examples seems to indicate it will iterate through all rasters and collect all values prior to going on to the next tool, but this is not the case in my experience.

I don't know if this will solve the number of bands issue, but it might.

Dave

Hi, I am having a similar problem with combining an iterator and the collect values tool with the Mosaic to New Raster tool. Basically I would like to collect a number of rasters from a geodatabase based on a Wildcard specification, then mosaic these into a new raster. However, I continue to get the ERROR 00157 "Input and target dataset should have the same number of bands". I'm not sure what the problem is. All the rasters have a single band and I am following almost the exact same process as ESRI's example of how to use the Collect Values tool. I have also attached an image of what my model looks like.
Thank you for the help.
0 Kudos