Alter model to iterate through rows

1818
7
Jump to solution
03-08-2017 10:27 AM
MichaelLenore1
New Contributor III

I have a model that iterates through feature classes, does a calculation, and puts out feature classes. I now need to run it on a GDB containing over 15000 fcs, which is time-consuming and cumbersome.

I wonder if anyone can help me alter the model so that, instead of iterating through a GDB, it will iterate through the rows in a single shapefile, do the same calculation, and put out a single shapefile with a new field containing the calculation result (or fill in an existing blank field). 

I have attached the toolbox here. The inputs will be changed: they will be a shapefile containing all New York State block groups, and a shapefile containing all New York State tax parcels. The model calculates the percentage of each block group that is residential, based on a field in the tax parcel shapefile called "GOSR_CAT". 

I suspect I need to use a different iterator (row selection?) but have no experience doing that. I don't know how to select a row, run the calculation, and fill in a field, all in the same shapefile. 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Esteemed Contributor

Instead of using Clip, try the Intersect (or Identity) tool on all your block groups (in a single feature class) with all your tax parcels (in another feature class). There are thousands of these so may want to subset one county to get it working the way you want. 

An overview of the Overlay toolset—Help | ArcGIS for Desktop 

View solution in original post

7 Replies
curtvprice
MVP Esteemed Contributor

There is a very nice example in the help

Examples of using iterators in ModelBuilder—Help | ArcGIS Desktop 

Most tools (including Calculate Field) process only the selected rows in a feature layer. (Iterate Row Selection outputs a layer [on each iteration] with the records selected, ready to work with.) You can't iterate through two shapefiles at once, so maybe you want to copy your row to a temp table (with Copy Rows) and use Get Field Value to get the field ID you would use to query the other shapefile on each iteration.

I would work on a small subset copy of your data-- this kind of thing can be pretty dangerous and you want to get it right before you let it rip on a big dataset. Even when you are running the whole thing, be sure you have a backup!

Do you have a good reason to do these one by one? I would think running a single massive Identity operation (or a few tiled operations not so large) would give you a table you could then process to get your answer.

0 Kudos
MichaelLenore1
New Contributor III

I don't have any reason to do them one by one! I don't quite get your drift re: "identity operation" but would welcome suggestions to get this result. 

0 Kudos
curtvprice
MVP Esteemed Contributor

Instead of using Clip, try the Intersect (or Identity) tool on all your block groups (in a single feature class) with all your tax parcels (in another feature class). There are thousands of these so may want to subset one county to get it working the way you want. 

An overview of the Overlay toolset—Help | ArcGIS for Desktop 

MichaelLenore1
New Contributor III

Ah, I see. Unfortunately I have to clip the tax parcels with the block groups, in order to avoid capturing area that's not in the block group. 

0 Kudos
curtvprice
MVP Esteemed Contributor

Intersect and Identity do the clip you want to do, and bring the attributes along so you can do your tabulations. Try it.

MichaelLenore1
New Contributor III

Amazing! It worked perfectly and saved tons of time. I ran it for one county's worth of block groups and got the same results as my model. So fast. Perfect. Thanks!