Solved

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

  • 26 March 2020
  • 3 replies
  • 37 views

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?

icon

Best answer by bwn 26 March 2020, 02:03

View original

3 replies

Badge +3

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.

Userlevel 4

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.

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

Reply