Solved

Iterate parameter values for multiple transformers

  • 15 August 2019
  • 7 replies
  • 3 views

Hi,

I'm relatively new to FME but am interested in running a workbench that loops/iterates parameter values (Neighbour Finder distance, Bufferer distance, and a number value in a tester) multiple times.

E.g. I want to generate outputs with a buffer distance of 5000, 10000, 15000, neighbour counts of 4,5,6 etc.

What is the best way to set a workbench running, that will generate multiple different outputs, based on iterating through parameter values, naming outputs accordingly?

 

I wish to end up with multiple outputs in a format similar to

 

output_$BufferDistance_$NeighbourDistance_$NumberValue

icon

Best answer by erik_jan 15 August 2019, 16:11

View original

7 replies

Userlevel 5
Badge +25

For looping you should take a look at custom transformers, that in combination with a fanout on the output filenames could do the trick. The FME Desktop Advanced course covers that. It's not a very easy thing to master though.

Somewhat easier perhaps is to set up one workspace that does the Neighbor finding, buffering and testing, create published parameters for the relevant values and then create a second workspace that runs the first one through a WorkspaceRunner. Feed that second workspace with an Excel file containing the values you want to put in the parameters.

 

Userlevel 2
Badge +16

I would store the different values for the parameters in a file (Excel, CSV or similar).

Then use a reader to read the combination line by line.

Use the values in a WorkSpaceRunner transformer to run a workspace that uses the single combination and create the output.

Each line in the file would trigger the workspace to run with a different combination, creating the output as requested.

The name of the output file would use the published parameters like this:

output_$(BufferDistance)_$(NeighbourDistance)_$(NumberValue)

Hope this helps.

Userlevel 1
Badge +21

In addition to the workspace runner suggestion, consider whether you need to 'loop' at all. Often you can just clone your inputs

Example: take multiple parameters, split to a list, explode the list to create multiple features each with an attribute containing individual parameter, buffer, write to different output files names according to the individual parameter

multiple_parameters.fmw

I would store the different values for the parameters in a file (Excel, CSV or similar).

Then use a reader to read the combination line by line.

Use the values in a WorkSpaceRunner transformer to run a workspace that uses the single combination and create the output.

Each line in the file would trigger the workspace to run with a different combination, creating the output as requested.

The name of the output file would use the published parameters like this:

output_$(BufferDistance)_$(NeighbourDistance)_$(NumberValue)

Hope this helps.

Many thanks - this seems clearest for me to follow. Will update if it is any harder than it sounds!

For looping you should take a look at custom transformers, that in combination with a fanout on the output filenames could do the trick. The FME Desktop Advanced course covers that. It's not a very easy thing to master though.

Somewhat easier perhaps is to set up one workspace that does the Neighbor finding, buffering and testing, create published parameters for the relevant values and then create a second workspace that runs the first one through a WorkspaceRunner. Feed that second workspace with an Excel file containing the values you want to put in the parameters.

 

Thanks, will investigate the custom transformers as long term they will be useful to master I suspect. Immediate priority is getting this job done so will go with the easier solution proposed

In addition to the workspace runner suggestion, consider whether you need to 'loop' at all. Often you can just clone your inputs

Example: take multiple parameters, split to a list, explode the list to create multiple features each with an attribute containing individual parameter, buffer, write to different output files names according to the individual parameter

multiple_parameters.fmw

Thanks for this - at the time I must admit I didn't quite follow, but after some more familiarity with the software I think this is actually a good answer answer. I like the way it doesn't rely on an external list. Am I right to think that for multiple parameters you would essentially be chaining together attribute splitters and list exploders?

Userlevel 1
Badge +21

Thanks for this - at the time I must admit I didn't quite follow, but after some more familiarity with the software I think this is actually a good answer answer. I like the way it doesn't rely on an external list. Am I right to think that for multiple parameters you would essentially be chaining together attribute splitters and list exploders?

That would be one way to do it, there are various other possibilities if you want to generate all permutations of parameter combinations

Reply