Finding index of nearest point in numpy arrays of x and y coordinates

前端 未结 3 2114
陌清茗
陌清茗 2020-11-27 10:41

I have two 2d numpy arrays: x_array contains positional information in the x-direction, y_array contains positions in the y-direction.

I then have a long list of x,y

3条回答
  •  Happy的楠姐
    2020-11-27 11:15

    If you can massage your data into the right format, a fast way to go is to use the methods in scipy.spatial.distance:

    http://docs.scipy.org/doc/scipy/reference/spatial.distance.html

    In particular pdist and cdist provide fast ways to calculate pairwise distances.

提交回复
热议问题