Near analysis within a single feature

481
1
05-01-2014 03:32 PM
Emilbrundage
New Contributor III
Greetings,

I would like to code a near analysis that generates the distance from each point in a point feature to its nearest neighbor within the same feature. Near Analysis and the like all require an Input feature and a different Near feature. Is there a way to get distance between nearest points in the same feature?

If there isn't I'll have to select each point one at a time in the input feature, export selection to a new feature, switch selection on the input feature so that the exported point is ignored, and perform the near analysis with each created feature point. Then bring that data from each exported feature point back into the input feature, as far as I can tell. This would take big chunks of time on large point features.
Tags (2)
0 Kudos
1 Reply
RichardFairhurst
MVP Honored Contributor
Most tools, like Spatial Join and Intersect, let you use the same feature class as the input for both the input and spatially related data sources, and the Generate Near Table should work for what you need.  You would always have to get at least 2 nearest points for each input point and then eliminate all records where the input and Near FIDs are the same (using a definition query, select and delete identical FID records in an edit session, or export just FIDs that are not identical).

Writing a script to do this is just reinventing the wheel, because you will have to do the identical tests as the above, and your suggested approach would be much less efficient than just permitting a tool to create self matches and eliminating the duplicates.
0 Kudos