Is there a scipy/numpy method to get the indices for nearest interpolation? Is there a scipy/numpy method to get the indices for nearest interpolation? numpy numpy

Is there a scipy/numpy method to get the indices for nearest interpolation?


k-D trees are commonly used to partition multidimensional data in order to perform fast nearest-neighbour searches.

For example, scipy.interpolate.NearestNDInterpolator is essentially just a wrapper around scipy.spatial.cKDTree (see the source code here). cKDTree.query will return the nearest-neighbour indices as well as the corresponding distances for a given set of input coordinates.