Skip to main content
Solved

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

  • March 25, 2020
  • 3 replies
  • 632 views

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

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
Celebrity
  • 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
  • Author
  • 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.

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