Skip to main content
Question

NeighborFinder ID of closest neighbor

  • December 2, 2014
  • 2 replies
  • 75 views

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?
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

takashi
Celebrity
  • December 2, 2014
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

Forum|alt.badge.img+1
  • December 3, 2014
Thanks Takashi, works great.

 

 

- Daniel