Friday 20 November 2015

geoprocessing - Using Value from Iterate Feature Selection to Calculate Field in ArcMap 10.1 ModelBuilder


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



Answer



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.


http://imgur.com/blIVtCK


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



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...