Created
June 9, 2021 17:11
-
-
Save alexander0042/cf4103e3fbbd7d5a6bc949970dc61e09 to your computer and use it in GitHub Desktop.
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