Skip to content

Instantly share code, notes, and snippets.

@NimishMishra
Created April 22, 2019 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NimishMishra/ee52417f47e52473bf29513b55c3bfc0 to your computer and use it in GitHub Desktop.
Save NimishMishra/ee52417f47e52473bf29513b55c3bfc0 to your computer and use it in GitHub Desktop.
# 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