Skip to content

Instantly share code, notes, and snippets.

@NimishMishra
Created April 22, 2019 14:02
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/ae05cff674cf6d2ed3013d265d0dde3b to your computer and use it in GitHub Desktop.
Save NimishMishra/ae05cff674cf6d2ed3013d265d0dde3b to your computer and use it in GitHub Desktop.
def load_data(FILEPATH):
ds = gdal.Open(FILEPATH)
return ds
# Opens the data HDF file and returns as a dataframe
def read_dataset(SUBDATASET_NAME, FILEPATH):
dataset = load_data(FILEPATH)
path = ''
for sub, description in dataset.GetSubDatasets():
if (description.endswith(SUBDATASET_NAME)):
path = sub
break
if(path == ''):
print(SUBDATASET_NAME + ' not found')
return
subdataset = gdal.Open(path)
subdataset = subdataset.ReadAsArray()
subdataset = pd.DataFrame(subdataset)
return subdataset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment