Skip to content
Prev 21330 / 29559 Next

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

Hi Florian, Jonathan,

I remember experiencing similar issues a while back with MODIS (I think NDVI product), simply because the product metadata were not correct (scaling factor) and readGDAL() uses them by default for automatic scaling on import.
The trick was to import using as.is=TRUE and doing the scaling myself using values from the product description.

So in your case, that would mean:
# Raster import via `readGDAL`
sds.rg <- readGDAL(sds, as.is=TRUE)

You can also wrap that into raster if you prefer working with classes of the raster package.
r0 <- raster(readGDAL(sds, as.is=TRUE))
r <- (r0 - 15000) * 0.01

Hope this helps,
Best regards,
Lo?c