nsrdb.utilities.nearest_neighbor.knn

knn(df1, df2, labels=('latitude', 'longitude'), k=1)[source]

Get nearest neighbors for data sets.

Parameters:
  • df1/df2 (pd.DataFrame:) – Dataframes containing columns with the corresponding labels.

  • labels (tuple | list) – Column labels corresponding to the columns in df1/df2.

  • k (int) – Number of nearest neighbors to return

Returns:

  • dist (ndarray) – Distance array in decimal degrees.

  • indicies (ndarray) – 2D array of row indicies in df1 that match df2. df1[df1.index[indicies[i]]] is closest to df2[df2.index[i]]