ListHistogrammer

From fmepedia

ListHistogrammer is a Workbench Transformer.


Computes a histogram of the values found in a list, and returns these in a new list attribute on the feature. The new list will be sorted so that the value with the most occurrences will be first.

somelist{0}.val = 'apple'
somelist{1}.val = 'donut'
somelist{2}.val = 'aardvark'
somelist{3}.val = 'apple'
somelist{4}.val = 'aardvark'
somelist{5}.val = 'apple'

Then the resulting feature will have this list attribute:

_histogram{0}.value = 'apple'
_histogram{0}.count = 3
_histogram{1}.value = 'aardvark'
_histogram{1}.count = 2
_histogram{2}.value = 'donut'
_histogram{2}.count = 1

The histogram name can be changed, allowing you to have multiple histograms attached to one feature.



Example

The attached workspace shows an example use of the ListHistogrammer transformer.

In this example the user needs to count how many features there are of each type (zone) in a set of zoning data. This can be achieved by creating an artificial aggregate and list of the source data and running it through the ListHistogrammer.

The workspace actually goes one step further by having a custom transformer that converts the histogram into a set of attributes and values.


Workspace Screenshot


Output Screenshot

The data as shown in the FME Viewer reveals there are 21 different zones, with (for example) 14 features of the zone type CS.

Attached Files
filesizedate
ListHistogrammer Example.zip94.4 kB11/11/08
listhistogrammer example output.jpg43.3 kB11/11/08
listhistogrammer example.jpg108.5 kB11/11/08
User Comments Add a new comment