I have two dataframes A and B consisting of latitude longitude coordinates of points. For each point in A I want to find the k-nearest neighbours in B. Currently, I calculate the distance from each point in A to all the points in B (using rdist.earth() in fields package), sort the points of B by distance and select the k nearest ones. Is there a more efficient way to do this? Function knearneigh {spdep} (using knn() of VR) does something similar but for a matrix with itself and not with another matrix. Is there a function that already does what I want and I could not find? Thanks Angel