2 iterators in the same model builder

2838
12
11-22-2021 06:09 PM
SAV
by
New Contributor II

Hi all! I am facing a problem because I know is not possible to include 2 iterators in the same model builder. I have 10 features (polygons) in a shapefile and 1000 rasters in a folder. I want to calculate for each polygon the zonal statistical as a table for each raster. Therefore, I need to use:

  1. Iterate feature selection to avoid the problem of overlapping polygons and iterate each polygon
  2. Iterate raster to make the iteration of each raster in each polygon

Therefore, I need two iterators, any idea on how to overcome this problem?

I am trying by creating a submodel and a model as shown in the images below but without too much success

submodel2.JPGmodel.JPG

 

Thank you!

 

 

0 Kudos
12 Replies
curtvprice
MVP Esteemed Contributor

You are missing the Collect Values tool in your submodel, then the submodel will pass back the generated list of rasters.. See the help for an example. (UPDATED LINK)

In ArcGIS Pro, Zonal Statistics as Table has been updated to support overlapping polygons. 

 

0 Kudos
SAV
by
New Contributor II

I have changed the submodel as you said including the collect values tool. I have run it and seems to work fine.

 

submodel.JPG

However, in the main model, I can not select the output of the submodel (Input value raster) in the zonal statistical as table

model.JPG

I still could not do it. I do not have license of ArcGis Pro!

 

Thank you!

 

Sara

0 Kudos
curtvprice
MVP Esteemed Contributor

1. You need to do the zonal statistics in the submodel. This example in the help (this is Pro but it applies to ArcMap too) shows this, the processing has to happen in the "inner loop", then each inner iteration set of results can be passed back up. You need to be careful to name your outputs uniquely using model variables so each zonalstats output table doesn't get overwritten, e.g. %shedname%_%rastername%_tbl.  It gets really complicated fast which is why we often use Python for complex iterations like this.

2. There are tools to process overlapping polygons in ArcMap available! Here are two toolboxes to check out.

Spatial Analyst Supplemental Tools

NAWQA Area-Characterization Toolbox

3. You said you don't have a Pro license. This is not true, although you may not have an install set up, but legally if you are licensed for ArcMap you are also licensed for Pro. If you don't have a site administrator to help you with this, contact Esri customer service and they can set you up with a license.

Hope this helps!

0 Kudos
curtvprice
MVP Esteemed Contributor

Just to prove it can be done, here is an example I worked up for the good of the thread.

(The Calculate Value tool in the main model was needed because the iterator generates "fieldname #" for the field name on each iteration, I cleaned it up with the Calculate Value expression %Polygon ID field%[-2:], output data type Field.)

model.jpgsubmodel.jpg

0 Kudos
SaraAV
by
New Contributor

I just got installed ArcGIS 2.8. I am about to run the model builder in ArcGIS pro, but as far as I read to consider the overlapping polygons, I do not have to change anything in the options, right? the zonal statistics as table in ArcGIS 2.8 Pro considers the overlapping polygons as default right? Thank you!

 

It is the same person (Sara), but from my organization account!

0 Kudos
curtvprice
MVP Esteemed Contributor

Note if you use Pro, you don't need to iterate the polygons, you can just iterate on the rasters in a single model. The ModelBuilder workflow I showed above processes each polygon one at a time so it would work in ArcMap.

As for Zonal Statistics As Table processing overlapping features, read the fine manual. At least it is advertised that way - but I always trust, but verify!

  • If the Input raster or feature zone data (in_zone_data in Python) has overlapping features, the zonal analysis will be performed for each individual feature.

0 Kudos
SAV
by
New Contributor II

Hi, sorry for keeping asking, but I am having some problems to run it in ArcGIS Pro. 

I am having issues to name the tables with the same name of my rasters because the extension TIF of the raster. I am using parse path, but I am not able to making it work in ArcGIS Pro. As far as I know, in ArcMap, you use %Value% to name the files once you extract the name without extension from parse path.

 

Also, when I am iterating over the  raster files, I do not got the symbol of the three arrows circling as I got in model builder of ArcMap.

 

Could you please help me to fix these issues?

 

I put an image of what I got until now in the model builder in ArcGIS pro.

Capture.PNG

and this is how the zonal statistical as table looks...

Capture2.PNG

0 Kudos
curtvprice
MVP Esteemed Contributor

The thing in percents is a model variable, not a default thing I think you think it is. I don't see a %Value% variable in your model anywhere. This won't work because there is no variable to substitute so it will use the text "%Value%" and %'s aren't allowed for items in the geodatabase. %Name (2)%_tbl may work for the output to your zonal statistics as table - though you want to connect the variable Name (2) to the Zonal Statistics As Table tool as a precondition to make sure the Parse Path runs first.

0 Kudos
SAV
by
New Contributor II

When I am trying to use %Name (2)%_tbl as a name, I have the following error %Name (2)%_tbl must not contain spaces.

To do the precondition I have done the following in the Zonal Statistics as table

Capture3.PNG

0 Kudos