[Gdal-dev] import from HDF4 Modis (Help!)

Ivan Lucena ILucena at clarku.edu
Wed Jul 12 10:56:05 EDT 2006


Hi there,

	If I understood the HDF4 driver documentation correctly there is
a two step approach to extract data from those files.	First use
gdalinfo to check the files subdataset names:

/**************
*
*/
C:/Data> gdalinfo MOD13A2_A2002049_h13v13_004_2003206105134.hdf
Driver: HDF4/Hierarchical Data Format Release 4
Size is 512, 512
Coordinate System is `'
...
...
...
Subdatasets:
 
SUBDATASET_1_NAME=HDF4_EOS:EOS_GRID:"MOD13A2_A2002049_h13v13_004_2003206
105134.hdf":MODIS_Grid_16DAY_1km_VI:1 km 16 days NDVI
  SUBDATASET_1_DESC=[1200x1200] 1 km 16 days NDVI (16-bit integer)
 
SUBDATASET_2_NAME=HDF4_EOS:EOS_GRID:"MOD13A2_A2002049_h13v13_004_2003206
105134.hdf":MODIS_Grid_16DAY_1km_VI:1 km 16 days EVI
  SUBDATASET_2_DESC=[1200x1200] 1 km 16 days EVI (16-bit integer)
 
SUBDATASET_3_NAME=HDF4_EOS:EOS_GRID:"MOD13A2_A2002049_h13v13_004_2003206
105134.hdf":MODIS_Grid_16DAY_1km_VI:1 km 16 days NDVI Quality
  SUBDATASET_3_DESC=[1200x1200] 1 km 16 days NDVI Quality (16-bit
unsigned integer)
...
 
SUBDATASET_11_NAME=HDF4_EOS:EOS_GRID:"MOD13A2_A2002049_h13v13_004_200320
6105134.hdf":MODIS_Grid_16DAY_1km_VI:1 km 16 days average relative
azimuth angle
  SUBDATASET_11_DESC=[1200x1200] 1 km 16 days average relative azimuth
angle (16-bit integer)
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)
/*
 *
 **************/

	And then select the subdataset to be read by gdalinfo or
gdaltranslate, possibly by gdalwarp too I guess.

/**************
*
*/
C:/Data> gdalinfo
HDF4_EOS:EOS_GRID:"MOD13A2_A2002049_h13v13_004_20032061
05134.hdf":MODIS_Grid_16DAY_1km_VI:1
Driver: HDF4Image/HDF4 Dataset
Size is 0, 0
Coordinate System is:
PROJCS["unnamed",
    GEOGCS["Unknown datum based upon the custom spheroid",
        DATUM["Not specified (based on custom spheroid)",
            SPHEROID["Custom spheroid",6371007.181,0]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433]],
    PROJECTION["Sinusoidal"],
    PARAMETER["longitude_of_center",0],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["Meter",1]]
Origin = (-5559752.598333,-4447802.078667)
Pixel Size = (926.62543306,-926.62543306)
...
...
...
Corner Coordinates:
Upper Left  (-5559752.598,-4447802.079)
Lower Left  (-5559752.598,-4447802.079)
Upper Right (-5559752.598,-4447802.079)
Lower Right (-5559752.598,-4447802.079)
Center      (-5559752.598,-4447802.079)

C:\Data>gdal_translate -of gtiff
HDF4_EOS:EOS_GRID:MOD13A2_A2002049_h13v13_004_2003206105134.hdf:MODIS_Gr
id_16DAY_1km_VI:1 test.tif
Input file size is 0, 0
-srcwin 0 0 0 0 falls outside raster size of 0x0
or is otherwise illegal.
/*
 *
 **************/

	The good news is that gdalinfo recognized the projection system,
but the bad one is that gdal_translate doesn't get it at all. I tried to
inform -srcwin 0 0 1200 1200, but it doesn't help.

	Let's check the inconstancies here.	It looks like there is
something wrong going on in the HDF4 Driver, because it can not
differentiate the subdataset name, they are all coming as
"MODIS_Grid_16DAY_1km_VI:1".

	If you use the Pedro Vincent's HDFExplorer
(http://www.space-research.org) you can see that there is 11 subdatasets
by the name of

1 Km 16 days NDVI
1 Kn 16 days EVI
1 Km 16 days NDVI Quality
1 Kn 16 days EVI Quality
1 Km 16 days red reflectance
1 Kn 16 days NIR reflectance
1 Km 16 days blue reflectance
1 Kn 16 days MIR reflectance
1 Km 16 days average view zenith angle
1 Km 16 days average sun zenith angle
1 Km 16 days average relative zenith angle

	Does anybody have a clue of how to make it work? Is there
anything that I am doing that is wrong or is there any workaround a know
problem?

	I will really appreciate any idea even to make changes in the
code. I can do that too if that is the case.

Thanks,

Ivan




More information about the Gdal-dev mailing list