`
lat, lon = dataset['latitude'], dataset['longitude']
np.min(np.abs(coordinates['point1'][0] - lat[:]))
stack the latitude and longitude into 1 array
latlon = np.stack([lat, lon], -1)
get euclidean distance between latlon and the point we're looking for, as an array
NOTE: this is not the great circle distance, so it's not exactly the best point, always, but will usually be right
dists = np.linalg.norm(latlon - np.array(list(coordinates['point1'])), axis=-1)
gets the index of the minimum distance (of the flattened array)
min_dist_idx = np.argmin(dists)
min_dist_y = min_dist_idx // dists.shape[1]
min_dist_x = min_dist_idx % dists.shape[1]
latlon[min_dist_y, min_dist_x]
`
`
lat, lon = dataset['latitude'], dataset['longitude']
np.min(np.abs(coordinates['point1'][0] - lat[:]))
stack the latitude and longitude into 1 array
latlon = np.stack([lat, lon], -1)
get euclidean distance between latlon and the point we're looking for, as an array
NOTE: this is not the great circle distance, so it's not exactly the best point, always, but will usually be right
dists = np.linalg.norm(latlon - np.array(list(coordinates['point1'])), axis=-1)
gets the index of the minimum distance (of the flattened array)
min_dist_idx = np.argmin(dists)
min_dist_y = min_dist_idx // dists.shape[1]
min_dist_x = min_dist_idx % dists.shape[1]
latlon[min_dist_y, min_dist_x]
`