Created
April 22, 2019 14:04
-
-
Save NimishMishra/ee52417f47e52473bf29513b55c3bfc0 to your computer and use it in GitHub Desktop.
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
# Loads the HDF file, gets the Latitude subdataset and returns the information of the nearest pixel to specified position | |
def find_latitude_position(CITY_LATITUDE, FILEPATH): | |
dataset_to_load = 'Latitude (32-bit floating-point)' | |
latitude_dataframe = read_dataset(dataset_to_load, FILEPATH) | |
min_diff = 100 | |
row_number = -1 | |
column_number = -1 | |
rows = latitude_dataframe.shape[0] | |
columns = latitude_dataframe.shape[1] | |
for i in range(rows): | |
for j in range(columns): | |
lat = latitude_dataframe.iloc[i][j] | |
diff = np.abs(lat - CITY_LATITUDE) | |
if(diff < min_diff): | |
min_diff = diff | |
row_number = i | |
column_number = j | |
found_lat = lat | |
if(row_number == -1 or column_number == -1): | |
print("Latitude not found. You might have chosen wrong scene") | |
return latitude_dataframe, row_number, column_number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment