Iteration procedure in model builder in ArcGIS9.3.1

702
4
04-05-2012 11:37 PM
MikeMichaelides
New Contributor
Hello. I need help regarding an iteration procedure in model builder ArcGIS9.3.1
My data are
1. A fishnet (grid) with an id for every rectangle
2. A number of buildings with attributes like what material is used for construction and building height.

I want to select the buildings with specific construction material and a range of building height based on their location in the fishnet (the buildings should have their center in  a specific rectangle) and at the end i want to have a table of frequencies of the buildings based on those attributes saved on my pc.
I know how to do this, but i don't know how to iterate the model to automatically take separately every single rectangle (i mean every record of that table) of the fishnet and to follow the pre-mentioned procedure and make me separate tables of frequencies based on the id of every rectangle.

i attach a picture of my model. just FYI the layer "kannavos" means the fishnet.

I hope you understand my need.

Thanks in advance
Mike
0 Kudos
4 Replies
curtvprice
MVP Esteemed Contributor
I know how to do this, but i don't know how to iterate the model to automatically take separately every single rectangle (i mean every record of that table) of the fishnet and to follow the pre-mentioned procedure and make me separate tables of frequencies based on the id of every rectangle.


This is much more difficult using 9.3 of course. On each iteration you want to calculate your select expression using the Calculate Value tool. You also need to name your output with a name including %n% (or a value derived from that using another Calculate Value) so the outputs will not overwrite on each iteration.

I think the easiest way to run the iteration is to number your fishnet polygons with a field from zero to N. Then you can easily calculate a select expression using %n%, for example "FISHID = %n%".  After you do the selection, run Get Count and in the model properties set your Get Count output to be the a while condition (the model will loop until your count variable is false (zero)) 

There's an example of using Get Count to stop the model in the online help.
0 Kudos
MikeMichaelides
New Contributor
Dear Curtis thanks for your reply. First can you be a little more specific, like with the steps to follow?
The "Calculate Value" needs a python expression in which I'm not familiar.
Also i found this script tool "iterate field value", but when i incorporate it in my model it keeps popping an error 000358.
I attach a picture of the incorporation in case it may help you.
Thank you again for your interest
Mike
0 Kudos
curtvprice
MVP Esteemed Contributor
The script you found looks like an easier approach than I came up with, in fact it seems to implement the 10.x iteration in the 9.x Model Builder without having to futz with Calculate Value python code. I'm guessing the tool you found is the Iterate Field Value Model Example - Case Study in the Geoprocessing Model and Script Tool Gallery.

This tool is really well documented. I suggest following its help - this is a better solution than I posted. As for your error message, I'm guessing "%n%" is not a valid argument, since it is a reserved read-only variable that evaluates to a number.
0 Kudos
MikeMichaelides
New Contributor
Dear Curtis hello. Thanks again for your interest. I finally got it working. The problem is that i was incorporating in my model the "Iterate Field Value" (Script Tool) and not the "Iterate Field Value" (Model). When i copied the entire "Iterate Field Value" (Model) in my model and made the necessary adjustments worked like a clock. I attach a photo of my final model.

Thanks again
Mike
0 Kudos