finding nearest neighbor for python numpy.ndarray in 3d-space
Here is the KDTree
way :
from scipy.spatial import KDTreedata= np.random.rand(10510,3)sample= np.random.rand(4350,3)kdtree=KDTree(data)
Then dist,points=kdtree.query(sample,2)
will give you the 2 best neighbors for the 4350 candidates in about one second.