Skip to content
Prev 21329 / 29559 Next

Cannot properly import MODIS MOD07_L2 .hdf files into R using rgdal

Hi Florian:

I took a look at your input, and I SUSPECT what you are seeing is a
problem with the documentation, but I agree you are seeing some odd
things.  Using only gdalUtils:

filename <- "MOD07_L2.A2013001.0835.006.2013001192145.hdf"
gdalinfo(modis_file,sd=8)
# Confirmed that your offset is -15000, scale is: 0.00999999977648258 or ~ 0.01

modis_trans <- gdal_translate(filename, dst_dataset = "tmp.tif",
sd_index = 8,output_Raster=TRUE)
summary(modis_trans)
# Confirmed the same values you got above
plot(modis_trans) # Looks good

modis_trans_conv <- (modis_trans+15000)*0.00999999977648258
summary(modis_trans_conv)
# Yep:
Min.        1.32690
1st Qu.     1.51870
Median      1.54110
3rd Qu.     1.59475
Max.        1.80070
NA's    53529.00000

I also confirmed the 15000 values in QGIS, which is a bit odd...

I'm not convinced this is a file translation issue, or at least one
the R community may be able to help with, since that subdataset is
documented as being a 16-bit integer (not unsigned) (QGIS also
confirmed this).  Also, gdalUtils should be using whatever GDAL you
have installed -- I've got the latest and greatest on my machine and
can replicate this issue, so if the translation is wrong, this is an
issue with the main GDAL developers (gdalUtils is simply wrapping
those functions).

So, I'd recommend a few email barrages:
1) Contact the MODIS folks and CONFIRM that once the gains/offsets are
applied, the output should be Kelvin, and not Celsius (which it
appears to be -- 1.6 deg C = 274.75 K, in the range you were looking
for).  Basically: they may have documented this wrong.
2) Contact the GDAL people and show them the gdal_translate and
gdalinfo results (run gdalUtils "gdal_translate" with the verbose=TRUE
flag and copy the "GDAL command being used:" line, which is the "pure"
gdal_translate command).
3) Contact the QGIS folks and let them know what you are seeing :)

--j


On Thu, Jul 17, 2014 at 2:27 AM, Florian Detsch
<florian.detsch at staff.uni-marburg.de> wrote: