How to iterate traces and feature selections

3781
10
Jump to solution
11-05-2020 12:27 PM
TimWhiteaker
Occasional Contributor II

I have a GP model that performs a trace and then assigns a long integer stored in the HydroID variable to a field in the edge layer.  Calculate Field has the Updated Trace Network as a precondition, so it waits until the trace is finished and there is a selection.  This works fine when I run the model.  The model is shown below, and is named "_Single Junction To Edges".

GP model to trace and assign values to results

The problem arises when I encapsulate this model in another model with an iterator.  I want to iterate through a selected set of junctions, and for each one, perform the trace and calculate the field.  However, calculate field appears to be running on the entire edge layer rather than the selection.  As the model runs, I can see the selections being made in the map, but the tool ignores them.  The model with the iterator, which includes "_Single Junction To Edges" as one of the tools, is shown below.

Iterator GP model

What do I need to do to get the iterator version to work like the standalone version with respect to using feature selections when it comes time to calculate the field?

I do acknowledge that outputting a group layer with the selection from the Trace tool in Pro 2.7, as discussed in this thread on working with trace results, may be the solution.  But it seems like the single model was working correctly, so I wonder if I'm just missing something that will make it work in the iterator.

I'm on Pro 2.6.

Tags (1)
0 Kudos
10 Replies
TimWhiteaker
Occasional Contributor II

My code worked in 2.7, so I did not bother revising it to take advantage of the new selection functionality, so I cannot give you concrete advice on how to deal with network trace results as selections.

Still, it seems the selection should be present on the feature layer when the trace is finished running.  This means the next time you access the network layer in your script or geoprocessing workflow, the selection should be there.  However, I have not tested this, so maybe I'm missing something. 

0 Kudos