Skip to main content
Hi, I have a polygon layer with each polygon having an ID. I have used the NeighborFinder transformer to get the distance to the nearest neighbor for each ID and I have only made a connection to the Candidate port, but not to the Base port in the NeighborFinder transformer so that all Candidates will be compared with all other Candidates, but will not be compared to themselves.

 

However, what I want is an attribute which has the ID of the nearest polygon. Can anyone advise on how this could be done?
Hi,

 

 

If you set the "Close Candidate List Name" parameter of the NeighborFinder - e.g. "_list", all attributes of matched neighbor(s) will be stored in the list.

 

e.g. _list{}.ID, _list{}.attr1, _list{}.attr2, and so on.

 

 

Since the NeighborFinder in FME 2014 sorts the list elements automatically by distance ascending, "_list{0}.<attribute name>" is the nearest neighbor's.

 

What’s Great 2014 – FME Desktop (http://blog.safe.com/2014/01/whats-great-2014-fme-desktop/)

 

In FME 2013 and earlier, the list will not be sorted, but you can use the ListSorter to sort them by "_list{}.distance".

 

 

And then, you can demote the first element of the list with the ListIndexer; set the "Demoted Attribute Prefix" parameter to a preferable prefix to prevent attribute name confliction.

 

 

Takashi
Thanks Takashi, works great.

 

 

- Daniel

Reply