Skip to main content
Solved

How to loop through a list of values while performing calculations on each value


Forum|alt.badge.img

Greetings, I’m needing to loop through a list of zones and run a series of calculations and spatial intersections that require a rather lengthy model. The trick is I need the model to still grab the next value in the list and run all the calculations accordingly. The only way I know to do this is to use a workspacerunner and call a separate workspace containing the list each time I need the next value. This seems highly inefficient so is there not a better way to setup a single workspace and have it loop through the list at the beginning, run all calculations, and proceed to next value in the list?

Best answer by bwn

Generally, looping is not required unless the output calculation result of an iteration is required as an input on the next iteration.

For everything else, FME will happily process all items in a List in parallel. If the results of all the Zones are independent from each other, then you can run them in one Workspace in a single Workflow that transforms all Zones results in parallel. If the Transformers need to be restricted to subsets of Features for each Zone, then use the "Group By" settings on those Transformers and ensuring that each Feature that needs to be grouped this way is attributed with the Zone identifier.

View original
Did this help you find an answer to your question?

3 replies

bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • Best Answer
  • March 26, 2020

Generally, looping is not required unless the output calculation result of an iteration is required as an input on the next iteration.

For everything else, FME will happily process all items in a List in parallel. If the results of all the Zones are independent from each other, then you can run them in one Workspace in a single Workflow that transforms all Zones results in parallel. If the Transformers need to be restricted to subsets of Features for each Zone, then use the "Group By" settings on those Transformers and ensuring that each Feature that needs to be grouped this way is attributed with the Zone identifier.


david_r
Evangelist
  • March 26, 2020

It is possible to use the ListExploder to convert each list item into separate features. It is then possible to use e.g. the AttributeCreator with adjacent feature handling to include the list values from neighboring indexes in the calculations.

If you have some Python knowledge, that can also be a very good alternative. Personally I use it quite a lot when doing advanced list manipulations.


Forum|alt.badge.img
david_r wrote:

It is possible to use the ListExploder to convert each list item into separate features. It is then possible to use e.g. the AttributeCreator with adjacent feature handling to include the list values from neighboring indexes in the calculations.

If you have some Python knowledge, that can also be a very good alternative. Personally I use it quite a lot when doing advanced list manipulations.

Thank y’all both. I will try these suggestions and respond back


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings