Opened 17 years ago
Closed 16 years ago
#1931 closed enhancement (wontfix)
HDF EOS: cannot retrieve band scale and offset
Reported by: | cermak | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: | dron |
Description
Hi,
From a MODIS MYD021km file I am trying to read band data including offset and scaling factors. Band data works just fine, but I can't get offset and scale. Without offset and scale the data is completely useless, so this seems to be a major issue to me.
Here is some sample code:
dsobj = gdal.Open('HDF4_EOS:EOS_SWATH:"myfile.hdf":MODIS_SWATH_Type_L1B:EV_1KM_RefSB') bandobj = dsobj.GetRasterBand(1) scale = bandobj.GetScale() offset = bandobj.GetOffset()
scale and offset variables are empty.
I am using a recent stable branch nightly. A sample file is at ftp://ladsweb.nascom.nasa.gov/allData/5/MYD021KM/2006/220/MYD021KM.A2006220.1330.005.2007140045620.hdf
For this file and data set, HDFView yields: radiance_scales = 0.0072957743,0.0051752976,0.0037723905,0.0029522364,0.0023176796,0.001162374,5.6182046E-4,0.0011558639,4.1845915E-4,9.5770456E-4,6.215421E-4,0.006355153,0.009465027,0.0069601014,0.0027906199 radiance_offsets = 316.9722,316.9722,316.9722,316.9722,316.9722,316.9722,316.9722,316.9722,316.9722,316.9722,316.9722,316.9722,316.9722,316.9722,316.9722
Thanks, Jan
Actually this is not a bug. It is not possible to fit bloated HDF dataset into GDAL data model. For this particular case, why should I fetch the 'radiance_scales' and 'radiance_offsets' numbers? There are 'reflectance_scales', 'reflectance_offsets', 'corrected_counts_scales' and 'corrected_counts_offsets'. How do I know what scales are the right scales? This logic should be implemented in high-level software, i.e. in your Python script. You should fetch the dataset metadata, search them for the right record (it is only possible with some extra knowledge of the product) and parse it. E.g., the following line produces a list of scales you requested:
Best regards, Andrey