Skip to content

Instantly share code, notes, and snippets.

@KrisYu
Created November 2, 2021 00:31
Show Gist options
  • Save KrisYu/297ef9f8f1175fb7b77b2dc67c2a230f to your computer and use it in GitHub Desktop.
Save KrisYu/297ef9f8f1175fb7b77b2dc67c2a230f to your computer and use it in GitHub Desktop.
distance from one point to array of points
# https://stackoverflow.com/questions/48609781/distance-between-one-point-and-rest-of-the-points-in-an-array/48610147
from scipy.spatial import distance
X = [(35.0456, -85.2672)]
coords = [(35.1174, -89.9711),
(35.9728, -83.9422),
(36.1667, -86.7833)]
distance.cdist(X, coords, 'euclidean')
array([[ 4.70444794, 1.6171966 , 1.88558331]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment