I'm beginning to learn Python coming from a C++ background. What I am looking for is a quick and easy way to find the closest (nearest neighbor) of some multidimensional query point in an 2D (numpy) array of multidimensional points (also numpy arrays). I know that scipy has a k-d tree, but I don't think this is what I want. First of all, I will be changing the values of the multidimensional points in the 2D array. Secondly, the position (coordinates) of each point in the 2D array matters as I will also be changing their neighbors.
I could write a function that goes through the 2D array and measures the distance between the query point and the points in the array while keeping track of the smallest one (using a scipy spatial distance function to measure distance). Is there is a built in function that does this? I am trying to avoid iterating over arrays in python as much as possible. I will also have numerous query points so there would be at least two "for loops" - one to iterate through the query points and for each query, a loop to iterate through the 2D array and find the minimum distance.
Thanks for any advice.