from scipy.spatial import cKDTree import numpy as np def match_nearest_neighbors(src_coords, tgt_coords) -> np.ndarray: tree = cKDTree(tgt_coords) dists, indices = tree.query(src_coords, k=1) return indices