I have this file which contains:

gdalinfo product.hdf
Coordinate System is `'
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)

as you can see, there are 24 bands What I need is just to extract the first band of the sub-dataset.


You can solve your problem by combining gdalwarp and gdal_translate:

gdalwarp -geoloc -t_srs epsg:3410 -tr 25000 25000 HDF4_SDS:UNKOWN:"product1.hdf":5 warped.tif
gdal_translate -b 1 warped.tif band1.tif

If you want all 24 bands separately, you can write a batch file with this content (on Linux it might be different):

FOR /L %%G IN (1,1,24) DO gdal_translate -b %%G warped.tif %%G.tif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.