# More creative or efficient solution for a proximity table (1:m) to all points within X distance, keeping obs. where no points fall within X distance?

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?

• 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