Skip to content

Instantly share code, notes, and snippets.

@sritchie
Created January 26, 2011 17:38
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 sritchie/797079 to your computer and use it in GitHub Desktop.
Save sritchie/797079 to your computer and use it in GitHub Desktop.
def prep_hdf(f):
from osgeo import gdal
print "Loading %s" % os.path.split(f.local)[1]
hdf = gdal.Open(f.local)
sdsdict = hdf.GetMetadata('SUBDATASETS')
sdslist = [sdsdict[k] for k in sdsdict.keys() if '_NAME' in k]
f.sds = [gdal.Open(n) for n in sdslist]
return f
def extract_data(aws, d, f, layer):
f.dataset = d.layer2name[layer]
f.layer = f.sds[layer-1].ReadAsArray(q) #layer indices are "normal" numbers - don't start at 0
f = process_into_npz(aws, d, f)
aws.done = 1
return aws, f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment