Skip to main content

Hi FME colleagues,

Neighbor finder transformer finds the nearest neighbor and allotting the same candidate to multiple bases. In my requirement, I need to pair the points from two set of data, but one base one candidate, that means one candidate should not be paired with more than one base.

for ex :

 

I have two sets of data, one is Blue and the other is REd. Now, first, the blue base comes and finding its closest candidate (good). Now the second base comes in and finds the same candidate which is already paired with the first blue base. this should not happen in my case, if it's already paired(i mean the closest candidate to some other base) then remove it from the candidate set. the candidate set should go smaller and smaller through the fme process.

now what our neighbor finder does is matching with all bases to first(1) candidates. many to one.

 

safe1can we achieve this using any transformer? or any workaround within FME using python caller?

Hi @f.kemminje​ ,

you can try something from this post to solve your problem:

https://community.safe.com/s/question/0D54Q00008aKQnaSAG/loop-through-featurejoiner

VariableRetriever -->Tester--> VariableSetter


Have you looked at the following related questions?

 

https://community.safe.com/s/question/0D54Q00008DpOYsSAN/neighborfinder-each-candidate-available-just-once

 

https://community.safe.com/s/question/0D54Q000080hTpkSAE/neighborfinder-and-excluding-candidates-after-matched

 

I think you would have to use the NeighborFinder in a loop which is tricky but not impossible.

https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Workbench/Workbench/looping_with_blocking_transformer.htm


safe3@jdh​ ,@connecter​ . Sorry, my question was not clear I think. Please refer to my image. links above are not excluding candidates if it is already matched. Also attached are my source MicroStation dgn file and fmw file. @david_r​ ,@mark2atsafe​ ,@Takashi Iijima​  Can you pls help me


As soon as "A" is matched with "1". then 1 should be excluded from the set. when b comes in, it should search only with 2 and 3, and now B will be matched to a closest candidate"2". and "2" excluded. and C will come and only one left, that is "3"


Hello again @f.kemminje​ ,

here is a workflow I build for you:

Point_NeighborfinderThe result table:

Point_Neighborfinder_2


safe4I used Python caller for this and achieved the target.

I used list exploder after neighbor finder, then stored the feature and its attributes to list @ pythoncaller's input method. 

And in the close() method, 

created one new list , and appended only valid feature and its attributes. No duplicate base or candidates.(ID not in List then only append)

I got the Result what I want.

Thanks For Everyone, who Answered my Q.

import fme
import fmeobjects
 
 
class FeatureProcessor(object):
    def __init__(self):
        self.featureList = s]
        self.mylist =  ]
        self.mylist2 =  ]
 
    def input(self,feature):
        self.featureList.append(feature)
        self.mylist.append(str(feature.getAttribute('tid')))
        self.mylist2.append(str(feature.getAttribute('cid')))
        #self.mylist2.append(feature.getAttribute('_creation_instance'))
        
 
    def close(self):
        outlist1= ]
        outlist2=2]
        mylist1=self.mylist
        mylist2=self.mylist2
        i = 0
        while i < len(mylist1):
            tid=(mylist1Âi])
            cid=(mylist2 i])
            if tid not in outlist1 and cid not in outlist2:
                outlist1.append(str(tid))
                outlist2.append(str(cid))
                print(tid)
                print(cid)
                self.featureList i].setAttribute('tid',tid)
                self.featureListri].setAttribute('cid',cid)
                self.pyoutput(self.featureListÂi])
            i = i + 1
 

 


Hello again @f.kemminje​ ,

here is a workflow I build for you:

Point_NeighborfinderThe result table:

Point_Neighborfinder_2

Thanks ! @connecter​ 


Thanks ! @connecter​ 

Thanks to All


Reply