[gdal-dev] Reading Modis level1b HDF4 data

Ivan ivan.lucena at pmldnet.com
Fri Feb 26 07:05:18 EST 2010


Martin,

Martin Raspaud wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> 
> I'm trying to access Modis data (Terra) with gdal through the python API.
> 
> I'm following the gdal tutorial http://www.gdal.org/gdal_tutorial.html, but get
> stuck at the rasterband reading part, with an error:
> Traceback (most recent call last):
>   File "gdaltest.py", line 24, in <module>
>     print 'Band Type=',gdal.GetDataTypeName(band.DataType)
> AttributeError: 'NoneType' object has no attribute 'DataType'
> 
> which means that the line:
> band = dataset.GetRasterBand(1)
> did return None.
> 
> Does anyone have an idea of what is going on ?

Try to use gdal.Open() on a subdataset and then call GetRasterBand(), example:

dataset = 
gdal.Open('HDF4_EOS:EOS_SWATH:"/local_disk/data/satellite/terra/MOD021KM.A2005161.0920.005.2005161194747.hdf":MODIS_SWATH_Type_L1B:EV_1KM_RefSB')
band = dataset.GetRasterBand(1)

See http://gdal.org/frmt_hdf4.html for more details on HDF subdatasets.


> I join the gdaltest.py and the dump of the file from gdalinfo (removed some
> lengthy metadata).
> 
> Thanks,
> Martin
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
> 
> iQEcBAEBAgAGBQJLh5HaAAoJEBdvyODiyJI4FoUH/jIbIM2s+rWq9V01CYRxjv+B
> PsvKJwIIL2saJ/ozuGlg6K3VMofW4eRRgOq877S6nnuVFSn1Ex0LnL01TKJIqoQF
> z9oOAY5knq/c2L37F2M1Y1ROg7hXyu0aTRsJD4+dkEBztu1DXSyC9j1ziYZYf52w
> /F0rWAkUjo1z+VuLnAbuqMX/41aHSLQCh5ksMaTv7+aw1QebAwL05IaKAKlEEbLE
> Mo8PpZfEl9NeoMyGkm8hK92dkpGxiFTozBmrGZy8zISmY5P3NpuUXDJGMQvX+OHY
> 3Hf+hHhYZhCXMVKNgM1ECs+SfFQFzegU9W+v5BFxL/VsuG3uwAhDJyhU/XuOcCY=
> =UQkq
> -----END PGP SIGNATURE-----
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


Regards,

Ivan


More information about the gdal-dev mailing list