[gdal-dev] extracting bands from HDF to GeoTiff

Daniele Romagnoli dany.geotools at gmail.com
Fri Jan 25 08:46:37 EST 2008


Hi Mattia,
Surely, someone in this mailing list will provide you a great tip.
Anyway, in the meantime, you can try with this command:

gdal_info -of GTiff -b 1 -b 2 -b 3 -co "PHOTOMETRIC=RGB" hdfsamplefile.hdf
tiftobewritten.tif

with the following notes:
-b 1 -b 2 -b3 allows to select the desired bands (instead of 1, 2, 3, select
the bands of your HDF dataset you need)
-co "PHOTOMETRIC=RGB" is a create option which allows to set the RGB color
interpretation.
hdfsamplefile.hdf is your source HDF file. Note that if your HDF contains
several subdatasets and you need some bands of a subdataset you need to
provide the subdataset name returned by gdalinfo on the
main file.

As an instance, calling gdalinfo on a HDF4, the last part of the information
you can obtain could be:
...
 SUBDATASET_48_NAME=HDF4_SDS:UNKNOWN:"c:\Work\data\hdf4\TOVS_DAILY_AM_870330_NG.HDF":157
 SUBDATASET_48_DESC=[180x360] Data-Set-99 (16-bit integer)
 SUBDATASET_49_NAME=HDF4_SDS:UNKNOWN:"c:\Work\data\hdf4\TOVS_DAILY_AM_870330_NG.HDF":160
 SUBDATASET_49_DESC=[180x360] Data-Set-101 (16-bit integer)
 SUBDATASET_50_NAME=HDF4_SDS:UNKNOWN:"c:\Work\data\hdf4\TOVS_DAILY_AM_870330_NG.HDF":164
 SUBDATASET_50_DESC=[5x180x360] Data-Set-103 (16-bit integer)
....

So, if you need to extract 3 bands from the subdataset #50 (having 5 bands),
you need to use
HDF4_SDS:UNKNOWN:"c:\Work\data\hdf4\TOVS_DAILY_AM_870330_NG.HDF":164
as sourcedataset of your gdal_translate command.

In case you encounter an error reporting that is not a recognised format try
removing the "C:" prefix in the subdataset name.

Let me know if this help.
Regards,
Daniele

On Jan 25, 2008 2:17 PM, mattia <mattia.parigiani at gmail.com> wrote:

> Hello all
>
> I am pretty new to GDAL and need to carry out a task relating HDF
> datasets..
>
> In particular I have HDF data with raster images inside and I would like
> to extract certain bands from the HDF band set and convert them into a
> Geotiff or some other RGB format..
> I guess this could be done using the gdal_translate utility or by writing
> some C snippet using the GDAL API...
> Can anyone help me out on this or give any suggestions...
> Thanks for your attention
>
> --
> Mattia
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
-------------------------------------------------------
Eng. Daniele Romagnoli
Software Engineer

GeoSolutions S.A.S.
Via Carignoni 51
55041 Camaiore (LU)
Italy

phone: +39 0584983027
fax:     +39 0584983027
mob:   +39 328 0559267


http://www.geo-solutions.it

-------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20080125/b1170f66/attachment.html


More information about the gdal-dev mailing list