2017-06-11 3 views
0

Ich versuche, ein HDF5-Bild in Python zu lesen (es ist mein erstes Mal). In hdfview sehe ich die subdatasets ohne Problem, aber in Python kann ich sie nicht lesen. Wenn ich tun:Leere Subdatasets beim Lesen von hdf5 in Python

f = gdal.Open(fileName, gdalconst.GA_ReadOnly) 
sub = f.GetSubDatasets()[0][0] 

Es gibt:

Traceback (most recent call last): File "", line 1, in sub=f.GetSubDatasets()[0][0]

IndexError: list index out of range

Jede Idee, warum geschehen ist das?

+0

Haben Sie h5py versucht? – MishaVacic

Antwort

0

Ich fand, wie es mit h5py zu tun, falls es jemand hilft, hier ist es:

f=h5py.File(fileName, "r") # Opens the file in reading mode 
datasetNames=[n for n in f.keys()] # identifies the datasets included in the image 
# for n in datasetNames: print(n) # print the names of the different datasets 
lat=f['LATITUDE'] # LATITUDE is a dataset in my file 
lat_at=lat.attrs['SCALING_FACTOR'] # SCALING_FACTOR is an attribut of the dataset LATITUDE 
Verwandte Themen