Skip to main content

Hi folks,

I've been scratching my head with this one a little.

I've got features each with an appended list of values (features that are within X distance). I would like to cycle through the the features and get the average value of matches stored (I have 7) within the list.

The list for each feature is not a fixed size, 0-50.

Any suggestions about what the best approach would be?

Hi,

1. Make sure every feature does have a unique id

2. Use ListExploder to create features for every list element

(you might want to take a look at 'Conflict Resolution')

3. Use StatisticsCalculator to calculate average value grouped by id


You can get the list average using a ListSummer and a ListElementCounter, followed by an ExpressionEvaluator with something like

@Value(_sum)/@double(@Value(_element_count))

This avoids using the ListExploder, which has a tendency to consume a lot of memory and slow down your translation considerably if you have many features and/or list elements. It also leaves you with the same number of output features and doesn't require a unique ID.


You can get the list average using a ListSummer and a ListElementCounter, followed by an ExpressionEvaluator with something like

@Value(_sum)/@double(@Value(_element_count))

This avoids using the ListExploder, which has a tendency to consume a lot of memory and slow down your translation considerably if you have many features and/or list elements. It also leaves you with the same number of output features and doesn't require a unique ID.

Nice suggestion! I will use this one myself in the future :)

 

 


Alternatively I think you can avoid exploding (an rebuilding) the list like this:

  1. Use a ListElementCounter to count the number of list elements, store that in an attribute (e.g. _elements)
  2. Use a ListSummer to sum the value of one list attribute, store that in a new attribute (e.g. _sum)
  3. Your average will be _sum divided _elements

You can get the list average using a ListSummer and a ListElementCounter, followed by an ExpressionEvaluator with something like

@Value(_sum)/@double(@Value(_element_count))

This avoids using the ListExploder, which has a tendency to consume a lot of memory and slow down your translation considerably if you have many features and/or list elements. It also leaves you with the same number of output features and doesn't require a unique ID.

Aaah, you beat me once again... :)

 

 


Aaah, you beat me once again... :)

 

 

On the other hand, I think your suggestion is a brilliant one 😉
On the other hand, I think your suggestion is a brilliant one ;-)
Almost as brilliant as yours ;)

 

 


And yet another option is.....the ListStatisticsCalculator from the FME Hub.


You can get the list average using a ListSummer and a ListElementCounter, followed by an ExpressionEvaluator with something like

@Value(_sum)/@double(@Value(_element_count))

This avoids using the ListExploder, which has a tendency to consume a lot of memory and slow down your translation considerably if you have many features and/or list elements. It also leaves you with the same number of output features and doesn't require a unique ID.

Thanks @jeroenstiers and @david_r , both great suggestions, I went with the latter option as I need this thing to scale up to handle lots of data. 

 

 

I got to say, FME Knowledge Center is a great resource. I always get multiple good answers, really quickly too! 

 

 

Thanks for all the help folks!

Reply