I have a proximity question. I am open to Arc or Python solutions. I am mainly asking because I think I am lacking a little creativity in approaching the situation.

The Situation

I have two point files (FileA, n = 100, and FileB, n = 10). I would like to know the nearest distance from each n of FileA to the n of FileB so long as the n of FileA is within X distance of FileB.

Current Approach

I am currently attempting an Arc solution via a 1:m spatial join, and then generating near distances based on the joined object IDs.

The Question/Problem

I'm trying to push my GIS skills and am at a creative roadblock as to how I could improve my solution. I see potential as I may be asking a roundabout buffer question, or perhaps missing some kind of crucial tool/intuition about the problem.

Apologies if this is not really a Stack appropriate question/format - will remove ASAP if so!

Solution via PostGIS (not quite comfortable with PostGIS yet): How to get distance between one point and all other points in a table?

  • 1
    I'm not sure about speed, but two methods I've used to solve similar problems are (1) shapely's nearest_points method and (2) scipy's KDTree. If n is very large, (2) might be faster because it requires a little more time to build the tree (but still quite fast) but can query very quickly. Your buffer approach may not be too bad, either. – Jon Feb 27 at 17:07

An ArcGIS solution here. The Point Distance Tool will calculate distances from each input point to all points in the other layer. You can delete the records greater than your tolerance. Finally, run Summary Statistics to find the minimum distance for each input Objectid/FID.

  • Perfect - thanks! Just the kind of creativity I was looking for. This is proving much faster than the several spatial joins I was attempting. – Reputable Misnomer Feb 28 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.