Skip to main content
Question

Summarising a list


Forum|alt.badge.img+1

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?

9 replies

Forum|alt.badge.img+7

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


david_r
Celebrity
  • March 8, 2017

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.


Forum|alt.badge.img+7
david_r wrote:

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 :)

 

 


redgeographics
Celebrity
Forum|alt.badge.img+50

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

redgeographics
Celebrity
Forum|alt.badge.img+50
david_r wrote:

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... :)

 

 


david_r
Celebrity
  • March 8, 2017
redgeographics wrote:
Aaah, you beat me once again... :)

 

 

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

redgeographics
Celebrity
Forum|alt.badge.img+50
david_r wrote:
On the other hand, I think your suggestion is a brilliant one ;-)
Almost as brilliant as yours ;)

 

 


itay
Supporter
Forum|alt.badge.img+17
  • Supporter
  • March 8, 2017

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


Forum|alt.badge.img+1
  • Author
  • March 8, 2017
david_r wrote:

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!

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