Skip to main content

I am trying to drop features in the PythonCaller (see below my code). I manage to delete attributes and geometry in the last else statment, but for some reason the feature itself is not deleted. The number of features in the input and output is namely the same, while the geometry is gone (Look at the image below)  . I just find it interesting to see that the features without geometry are still kept. Does anyone know how I can drop the features in the Pythoncaller in the else statement when I am removing the redundant geometry?afbeeldingafbeelding

import fmeobjects
 
def processFeature(feature):
 
        lstAttributes = feature.getAllAttributeNames()
        testList:=f'B-OI-KL_ET_MS_KABELBED-G']
 
        for lvl in lstAttributes:
            if lvl == 'igds_level_name':
                levelName = feature.getAttribute(lvl)
                if levelName in testList:
                    print(levelName)
                    #print(levelName)
                    for attr in lstAttributes:
                         if len(attr) > 10 and attrÂ-10:] == '.beheerder':
                             #print(attr 0:-10])
                             #print(feature.getAttribute(attr))
                             feature.setAttribute('Beheerder_Omschrijving', attrÂ0:-10])
                             feature.setAttribute('Beheerder_Naam', feature.getAttribute(attr))      
 
                else:
                    feature.removeAttribute(lvl) 
                    feature.removeGeometry() #here I remove the geometry
                            
     

 

You cannot use the function interface for this, you'll need to use the class interface. It's then as simple as not calling self.pyoutput(feature) for the features that you want to ignore.

See also https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/pythoncaller.htm