Closest Points Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abslat = np.abs(lats-stn_lat) | |
abslon= np.abs(lons-stn_lon) | |
c = np.maximum(abslon,abslat) | |
latlon_idx = np.argpartition(-c.flatten(), -4)[-4:] | |
x, y = np.unravel_index(latlon_idx,c.shape) | |
latlon_dist = c[x, y] | |
# Avoid divide by zero if exactly on point | |
latlon_dist=np.maximum(latlon_dist, 0.000001) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment