Find 3 nearest features

2120
3
12-02-2020 09:59 AM
NathanEnge
Esri Contributor

Does anybody have a methodology to return the "top 3" closest point features from another point feature class?

I have two point datasets. For each record in one dataset, I want to find the top 3 closest dataset in another.

The "Near Analysis" returns only one closest feature.

0 Kudos
3 Replies
DavidPike
MVP Frequent Contributor

You have the point distance tool Point Distance—Help | ArcGIS for Desktop

but the results could obviously be quite large.  a search radius would reduce this but obviously might not suit most use cases.

When you get the table you could then wrangle it, something like create a cursor and produce a dictionary of all input OIDs as a key, the value being a list of  a list - [[distance, OID], [distance, OID], [distance, OID]....].  Iterate over the dictionary, sort the values and select the 3 smallest values and grab the OIDs.

This wouldn't be very hard to implement, though I do hope someone has a more trivial way.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor
Robert_LeClair
Esri Notable Contributor

I know the Find Nearest tool in ArcGIS Insights does this rather easily.  In the UI, one can limit the search to a certain number of features and/or a distance.

0 Kudos