Hi @jono
Â
Could you specify what you mean with 'joining' and 'touching' features? Do I understand correctly that you want to get all attributes of all features touching the feature considered and then check what attributes are present in the neighboring features but not in the feature considered?
Â
In this case, there might be an 1-N relation unless you are certain there isn't
Â
What your looking for is essentially a DifferenceDetector. What I've done in similar situations is transfer the attributes from one feature (reference feature) to the other feature (comparison feature). I used a featureMerger on a key attribute, but you may need to use a spatialRelator instead. All of the attributes were prefixed with _ref_.
I then used a pythonCaller to loop through all the attributes and testes to see if _ref_X matched X, if not, then the attribute name was appended to a list attribute (_changeList{}).
You could then use a ListConcatenator to produce the single attribute you want.
Thanks jeroensiers, I'm sorry I should have been clearer. This only applies to lines which touch at the endpoints or areas which share a boundary. For example where 2 lines won't join (LineJoiner) or where 2 areas won't merge (Dissolver) only because of attribute differences each instance will need to be investigated to determine which attribute value is correct. It would be really helpful if it listed those attributes which differ between the two features.
Â
Thanks.
Â
Â
What your looking for is essentially a DifferenceDetector. What I've done in similar situations is transfer the attributes from one feature (reference feature) to the other feature (comparison feature). I used a featureMerger on a key attribute, but you may need to use a spatialRelator instead. All of the attributes were prefixed with _ref_.
I then used a pythonCaller to loop through all the attributes and testes to see if _ref_X matched X, if not, then the attribute name was appended to a list attribute (_changeList{}).
You could then use a ListConcatenator to produce the single attribute you want.
Thanks jdh, LineJoiner and Dissolver both produce a nice List when Accumulation mode=Merge attributes is selected, however I haven't come up with an easy solution to comparing the list attributes. Maybe it's time to learn Python...
Â
Wouldn't it be nice if there was a downloadable custom transformer for 'DifferenceDetector'?
Â
Â
Thanks jdh, LineJoiner and Dissolver both produce a nice List when Accumulation mode=Merge attributes is selected, however I haven't come up with an easy solution to comparing the list attributes. Maybe it's time to learn Python...
Â
Wouldn't it be nice if there was a downloadable custom transformer for 'DifferenceDetector'?
Â
Â
Sad;y, I'm not allowed to post transformers developed at work to the hub.
Â
Â
What your looking for is essentially a DifferenceDetector. What I've done in similar situations is transfer the attributes from one feature (reference feature) to the other feature (comparison feature). I used a featureMerger on a key attribute, but you may need to use a spatialRelator instead. All of the attributes were prefixed with _ref_.
I then used a pythonCaller to loop through all the attributes and testes to see if _ref_X matched X, if not, then the attribute name was appended to a list attribute (_changeList{}).
You could then use a ListConcatenator to produce the single attribute you want.
Understood, thanks for pointing me in the right direction.
Â
Â
Understood, thanks for pointing me in the right direction.
Â
Â
The key fmeobjects methods here are
Â
getAllAttributeNames() -> get all the attribute names
Â
getAttribute(attrName) -> get the value of the attribute
Â
setAttribute(attrName, attrValue) -> for the output changelist
Â
Â
There is some basic python fme explantions here:
Â
https://knowledge.safe.com/articles/706/python-and-fme-basics.htmlÂ
Â
the fmeobjectsAPI is
http://docs.safe.com/fme/html/FME_Objects_Python_API/index.htmlÂ
Â
stackoverflow is an excellent resource for general python questions
Â
Â
Hi @jonoÂ
The python code provided below will for every feature look for the list. For the first element it will get all attributes and the values of these attributes and store them in a dictionary. Next the code will loop through all attributes of every list element and if the value differs from the value of the first element, the attribute name is listed in the attribute 'attribute_with_different_values'.
import fme
import fmeobjects
import re
class FeatureProcessor(object):
    def __init__(self):
        self.name_list = '_list'
       Â
    def input(self,feature):
       Â
        attributes = feature.getAllAttributeNames()
       Â
        # Keep only those attributenames linked to the first feature of the list and only keep the
        # name of the attribute itself
        attributes_to_compare = lre.search('(?<=\.).*$', x).group(0) for x in attributes if re.search('\{0\}\.', x)]
       Â
        # Store those attributenames in a dictionary having the value of the attribute as value
        attributes_first_element = {}
        for cAttribute in attributes_to_compare:
            attributes_first_elementÂcAttribute] = feature.getAttribute("{}{{0}}.{}".format(self.name_list, cAttribute))
        # Now loop through all attributes for all features and check which of them have a different value
        attributes_with_different_values = set()
       Â
        attributes = ox for x in attributes if re.search('\{\d+\}\.', x)]
       Â
        for cAttribute in attributes:
            value = feature.getAttribute(cAttribute)
            name_attribute = re.search('(?<=\.).*$', cAttribute).group(0)
           Â
            if value != attributes_first_elementbname_attribute]:
               Â
                attributes_with_different_values.add(name_attribute)
               Â
        # Store all the attributes that have different values in one attribute to export
        feature.setAttribute('attribute_with_different_values', ','.join(attributes_with_different_values))
        self.pyoutput(feature)
       Â
    def close(self):
        pass
       Â
     Â
Hi @jonoÂ
The python code provided below will for every feature look for the list. For the first element it will get all attributes and the values of these attributes and store them in a dictionary. Next the code will loop through all attributes of every list element and if the value differs from the value of the first element, the attribute name is listed in the attribute 'attribute_with_different_values'.
import fme
import fmeobjects
import re
class FeatureProcessor(object):
    def __init__(self):
        self.name_list = '_list'
       Â
    def input(self,feature):
       Â
        attributes = feature.getAllAttributeNames()
       Â
        # Keep only those attributenames linked to the first feature of the list and only keep the
        # name of the attribute itself
        attributes_to_compare = lre.search('(?<=\.).*$', x).group(0) for x in attributes if re.search('\{0\}\.', x)]
       Â
        # Store those attributenames in a dictionary having the value of the attribute as value
        attributes_first_element = {}
        for cAttribute in attributes_to_compare:
            attributes_first_elementÂcAttribute] = feature.getAttribute("{}{{0}}.{}".format(self.name_list, cAttribute))
        # Now loop through all attributes for all features and check which of them have a different value
        attributes_with_different_values = set()
       Â
        attributes = ox for x in attributes if re.search('\{\d+\}\.', x)]
       Â
        for cAttribute in attributes:
            value = feature.getAttribute(cAttribute)
            name_attribute = re.search('(?<=\.).*$', cAttribute).group(0)
           Â
            if value != attributes_first_elementbname_attribute]:
               Â
                attributes_with_different_values.add(name_attribute)
               Â
        # Store all the attributes that have different values in one attribute to export
        feature.setAttribute('attribute_with_different_values', ','.join(attributes_with_different_values))
        self.pyoutput(feature)
       Â
    def close(self):
        pass
       Â
     Â
Many, many thanks @Jeroenstiers, you have gone far beyond the help that I expected!
Â
Â
Many, many thanks @Jeroenstiers, you have gone far beyond the help that I expected!
Â
Â
You're welcome!
Â
Hope this solves the issue. Could you close the question if it did?
Â
Â
Â
Hi @jonoÂ
The python code provided below will for every feature look for the list. For the first element it will get all attributes and the values of these attributes and store them in a dictionary. Next the code will loop through all attributes of every list element and if the value differs from the value of the first element, the attribute name is listed in the attribute 'attribute_with_different_values'.
import fme
import fmeobjects
import re
class FeatureProcessor(object):
    def __init__(self):
        self.name_list = '_list'
       Â
    def input(self,feature):
       Â
        attributes = feature.getAllAttributeNames()
       Â
        # Keep only those attributenames linked to the first feature of the list and only keep the
        # name of the attribute itself
        attributes_to_compare = lre.search('(?<=\.).*$', x).group(0) for x in attributes if re.search('\{0\}\.', x)]
       Â
        # Store those attributenames in a dictionary having the value of the attribute as value
        attributes_first_element = {}
        for cAttribute in attributes_to_compare:
            attributes_first_elementÂcAttribute] = feature.getAttribute("{}{{0}}.{}".format(self.name_list, cAttribute))
        # Now loop through all attributes for all features and check which of them have a different value
        attributes_with_different_values = set()
       Â
        attributes = ox for x in attributes if re.search('\{\d+\}\.', x)]
       Â
        for cAttribute in attributes:
            value = feature.getAttribute(cAttribute)
            name_attribute = re.search('(?<=\.).*$', cAttribute).group(0)
           Â
            if value != attributes_first_elementbname_attribute]:
               Â
                attributes_with_different_values.add(name_attribute)
               Â
        # Store all the attributes that have different values in one attribute to export
        feature.setAttribute('attribute_with_different_values', ','.join(attributes_with_different_values))
        self.pyoutput(feature)
       Â
    def close(self):
        pass
       Â
     Â
This works brilliantly and will save me so much time, well done!  I'm sure that this code will be useful for so many people.  Thanks again.
Â
Â