Skip to main content
Hello there, 

 

 

I have some data in the following structure (with some other columns not really of interest) which needs to be represented as features with only one input into each column;

 

 

 

 

Each feature represents a polygon; there needs to be just one code under 'TYPE' and one under 'TYPEAR'. Where there are more then one code in a column, i need those to become new features (taking the UniqueID of where it came from). The corresponding positions of the code in TYPE and TYPEAR are correct (ie 1st letter goes with 1st decimal value etc)

 

 

n represents the fact that I have many files like this with many 1000s of features in each one.

 

 

So, i used AttributeSplitter for 'TYPE' and also for 'TYPEAR', splitting by the comma, creating a list for each attribute. I then used ListExploder for _listTYPE{} and _listTYPEAR{} and created a new feature based on the lists. 

 

 

However, exploding by one list is all fine - eg Exploding  _listTYPE{} will create a feature for each letter code within a uniqueID - but as the TYPEAR attribute has not been exploded yet, there are still concatenated entries for the newly exploded TYPE attribute under TYPEAR. Performing the 2nd Exploder on  _listTYPEAR{} creates too many features.

 

 

As an example, looking at row 3 in the above table, there should be two features as thus;
  • 21321----A----5.4
  • 21321----B----6.5
but instead, by exploding both lists, you get;
  • 21321----A----5.4
  • 21321----A----6.5
  • 21321----B----5.4
  • 21321----B----6.5
So, for the above table, instead of the required 13 features, you would get 25

 

 

Does anyone know how to solve this?

 

thanks

 

 

This is a workaround i have come up with, please pick holes in it;

 

 

- AttributeSplitter on TYPE (creates _listTYPE{})

 

- AttributeSplitter on TYPEAR (creates _listTYPEAR{})

 

- 2 concurrent ListExploders on both lists, creating double the features

 

- FeatureMerger the two streams, grouped by PolygonID, joined by element_index
Good solution, shemnel.

 

This is another approach. Create a complex list and explode it.

 

 

Takashi
Another variation:

 

2 AttributeSplitters (not after each other, but both connected to the input) list name : _list + 1 ListExploder.
Or just as you already did:

 

AttributeSplitter for 'TYPE' and also for 'TYPEAR'

 

And, as they are ordered, use listelementcounter and listindexer{}.

 

 

 

Gio
There are many ways. I prefer to write Python script in fact.

 

-----

 

import fmeobjects

 

class FeatureProcessor(object):

 

    def __init__(self):

 

        pass

 

       

 

    def input(self, feature):

 

        s = ae.strip() for e in str(feature.getAttribute('TYPE')).split(',')]

 

        t = te.strip() for e in str(feature.getAttribute('TYPEAR')).split(',')]

 

        for type, typear in zip(s, t):

 

            f = feature.cloneAttributes()

 

            f.setAttribute('TYPE', type)

 

            f.setAttribute('TYPEAR', typear)

 

            self.pyoutput(f)

 

       

 

    def close(self):

 

        pass

 

-----

Reply