I have two polygon feature classes, an alignment layer and a parcels layer. I am trying to use ModelBuilder to create a tool that will do the follow:

  1. iterate through groups in a single field of a polygon alignment layer (ie select and iterate through certain attributes in a field with same names such as "tunnel", "portal", etc)
  2. Clip a parcel layer by each group
  3. Populate a new field in the parcel layer called "EsmtType" with the name of each group (group is called "Value" in model)
  4. Merge the clipped groups into one feature class

I have gotten steps 1 and 2 to function but I am stuck on step 3. I am not sure how I need to configure the "Calculate Field" tool in order to recognize the "Value" variant of the "Iterate Feature Selection" tool. I tried using the advice from this post Using a value from "iterate feature selection' to calculate a field but I couldn't figure out how to implement it for my situation.

Here is the model I have thus far: http://imgur.com/ji2nAJJ

I would also like advice on how to implement step 4, I am not sure if it would require integrating a model within a model.

Thank you so much!!! -kkaszas

  • Could you please describe how you use the alignment layer? – Aaron Jun 26 '13 at 22:01
  • Its a polygon layer that I am trying to use as the clip feature for my input parcel layer – kkaszas Jun 26 '13 at 22:19
  • Could you expand step four? Does the precondition prevent the merge from 'firing' too often? When I've run similar models, it has run a merge for each iteration, substantially increasing model run time...to an unacceptable level. – Mox Apr 22 '14 at 23:44

I remember struggling with this in ModelBuilder as well, and the method I eventually came up with is this:

enter image description here

An expression is built using the Calculate Value tool with Value as an inline variable. It will return a string containing the current Value which can be used as the expression for the Calculate Field tool.

  • When I try to change the default expression of calculate value to anything other than the default, the connector between "value" and "calculate value" disconnects. I was also having this problem before I was using "calculate value" and just trying to connect "Value" straight to "calculate field", whenever I would alter the expression or code block the connector would disappear. Here is a screen shot showing the defaults, any idea what to do about this? imgur.com/0Ls9tZx – kkaszas Jun 27 '13 at 18:21
  • Value should be set as a precondition to Calculate Value. This ensures that the expression is constructed after the current value is updated, so the connector between Value and Calculate Value should be a dotted line. You can then fill in the Python code. – Cindy Jayakumar Jun 28 '13 at 5:24

The solution to implementing step 3 was very simple. I actually didn't need to use "Calculate Value" before "Field Calculator" to make it work as @Arabella had suggested. The main piece of information that helped me was @Arabella telling me about preconditions. I set a connection between "Value" and "Field Calculator" as a "precondition" (which shows up as a dotted line), I then used the following expression in the field calculator: "%value%" and I set the expression type to PYTHON. This worked perfectly.

Below is a link to a screen shot of the functioning model (steps 1-3). I now need to implement step 4. The advice I have been given from the Esri forum is "To merge the clipped outputs you will need to use the Collect Values tool to collect the outputs of clip, make that output a parameter and drag that into a different model, the output of Collect Values would then be an input to the Merge Tool (data management)." I will test this.


EDIT: I have successfully implemented Step 4. I used the "Collect Values" tool to create a repository of my output clips. I then used the Merge Tool (data management) to create a single feature class, I made the output a parameter.

Tip: If you want to use this model but you dont want to iterate through selections of every record group then prior to running the tool, set a definition query (on the feature you want to use to clip by) to include only the attributes you want to iterate.

The final working tool:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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