[gdal-dev] Checking if a label exists in a HDF file

Anton Korosov anton.korosov at nersc.no
Thu Aug 4 05:24:06 EDT 2011


Hi, Antonio!
You can do that with the gdalinfo command prior to running a python script:

gdalinfo MODIS_FILE.hdf | grep EV_1KM_RefSB | wc -l

returns a number if subdataset EV_1KM_RefSB exist
return 0 if not.

triton:gdaltest>gdalinfo MYD02QKM.A2010217.1335.005.2010218190207.hdf | 
grep EV_1KM_RefSB | wc -l
0

triton:gdaltest>gdalinfo MOD021KM.A2010105.2120.005.2010106075131.hdf | 
grep EV_1KM_RefSB | wc -l
7

Anton
On 08/04/2011 10:10 AM, António Rocha wrote:
> Greetings
>
> I have a Python Script where I call gdalwarp binary (in Windows) to warp
> an image. But, before I run the gdalwarp I need to check if the file
> exists (DONE) and if a defined HDF layer exists. How can I check, using
> gdal, in a Script if a certain layer exists?
> THanks
> Antonio
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 6348 (20110803) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list