Created
April 22, 2019 14:02
-
-
Save NimishMishra/ae05cff674cf6d2ed3013d265d0dde3b 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
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