Question

AttributeManager with Group-By function?


Userlevel 1
Badge +8

I have some date with id-blocks, meaning there is a column where one and the same object is represented of several features, with different attribute values, but always with the same id for these features.

How many features there are per object varies.

I was thinking to build some 'decision-tree' in an AttributeManager to find the correct features of such an id-block to process further. Unfortunately, the AttributeManager is not a group-by transformer and I was wondering how can I group my data by id, and process the resulting group, before the next group is created and processed.


12 replies

Userlevel 3
Badge +26

What is the process you want to do in the AttributeManager? Perhaps there is another transformer with the group by option that will perform the same process.

Userlevel 1
Badge +8

What is the process you want to do in the AttributeManager? Perhaps there is another transformer with the group by option that will perform the same process.

I need to process the groups in a way like e.g.:

test if: column 1 has a value -> failed

else: get max value of column 2 and check if column 3 has no value -> passed

with the passed object:

test if: column 4 has specific value -> send feature to port 'delete'

else: send feature to port 'update/create'

Userlevel 3
Badge +26

I need to process the groups in a way like e.g.:

test if: column 1 has a value -> failed

else: get max value of column 2 and check if column 3 has no value -> passed

with the passed object:

test if: column 4 has specific value -> send feature to port 'delete'

else: send feature to port 'update/create'

If I'm understanding correctly, it sounds like you could use the Aggregator transformer with Group Processing set to the id-block, and the Accumulation Mode set to Merge Incoming Attributes. This should result in a single feature for each id-block containing all the columns. From there, you do your processing in the AttributeManager.

 

If you could upload a sample of the data, I could provide a more specific answer.

Userlevel 1
Badge +8

I need to process the groups in a way like e.g.:

test if: column 1 has a value -> failed

else: get max value of column 2 and check if column 3 has no value -> passed

with the passed object:

test if: column 4 has specific value -> send feature to port 'delete'

else: send feature to port 'update/create'

Sounds interesting, crux is, all the features have all the same columns. The data structure basically looks like this

 

image

Userlevel 3
Badge +26

I need to process the groups in a way like e.g.:

test if: column 1 has a value -> failed

else: get max value of column 2 and check if column 3 has no value -> passed

with the passed object:

test if: column 4 has specific value -> send feature to port 'delete'

else: send feature to port 'update/create'

I see. Unfortunately, I don't think you will find a neat solution completely in the AttributeManager. I think you will need a combination of transformers that might include the StatisticsCalculator (group by id-block, to get max of column 2) and Testers/Testfilters.

Userlevel 1
Badge +8

I need to process the groups in a way like e.g.:

test if: column 1 has a value -> failed

else: get max value of column 2 and check if column 3 has no value -> passed

with the passed object:

test if: column 4 has specific value -> send feature to port 'delete'

else: send feature to port 'update/create'

Yes, thats how I would to this as well, but how to keep all this 'group-specific'?

Userlevel 1
Badge +8

I need to process the groups in a way like e.g.:

test if: column 1 has a value -> failed

else: get max value of column 2 and check if column 3 has no value -> passed

with the passed object:

test if: column 4 has specific value -> send feature to port 'delete'

else: send feature to port 'update/create'

I mean I have no problem using several transformers to achieve my goal... I think the best thing would be if I could build the processing with a group in mind, wrap everything in a custom transformer and send only groups in.

But I have no idea on how to get the grouping stuff done.

Userlevel 4
Badge +36

What is the process you want to do in the AttributeManager? Perhaps there is another transformer with the group by option that will perform the same process.

Maybe you can aggregate the fetaures with a ListBuilder (group by your ID field) , and do your logic tests on the attributes in the List?

If you can provide us with some relevant sample data, and the results you want to get with those data, we may be able to help you better.

Userlevel 4
Badge +26

I need to process the groups in a way like e.g.:

test if: column 1 has a value -> failed

else: get max value of column 2 and check if column 3 has no value -> passed

with the passed object:

test if: column 4 has specific value -> send feature to port 'delete'

else: send feature to port 'update/create'

Custom Tansformers ​have a GroupBy option. After creating the CustomTransformer look in the Navagator on the left from inside the transformer. In the parallel processing settings somwhere is a group by option which you can expose as a parameter. I'd probably keep parallel processing level at None. But if you really want not have to worry about the groups or lists then this could be a good option

Badge +2

@Thomas Becker​ I suspect that Aggregator (with lists) plus a PythonCaller with a short python script along the lines illustrated towards the end of this will give you what you need.

Badge +3

Use Statistical calculator

group base on ID

choose count (check box ON)

This will give you new attribute , the features FME collected overall while grouping.

Badge +6

What I usually do, and I need a group-based Attribute Manager surprisingly often, is to create a custom transformer. Enable parallel processing and group by desired feature. The other way around, in my case, would be handling the 'grouping' by conditional formatting which is too cumbersome.

Reply