[Gdal-dev] gdal_translate

Andrey Kiselev dron at ak4719.spb.edu
Thu Oct 23 01:51:05 EDT 2003


On Wed, Oct 22, 2003 at 02:44:29PM -0600, David.Hildebrand at gov.ab.ca wrote:
> I have been trying to use gdal_translate with an HDF MODIS file.  How do I 
> specify a specific SDS from the file?  Do I specify it with the band 
> parameter or as part of the filename?  In the example below I want to 
> extract the first band from the "EV_1KM_RefSB" SDS and create aTIF file.
> 
> gdal_translate -ot UInt16 -b 2:1 
> Z:\modis\MOD021KM.A2003169.1845.004.2003170123719.hdf test
> Input file contains subdatasets. Please, select one of them for reading.

HDF files may contain several differently sized subdatasets. So you
should select one of them to proceed. First, use gdalinfo to get a list
of subdatasets with names and properties:

$ gdalinfo MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf 
Driver: HDF4/Hierarchical Data Format Release 4
Size is 512, 512
Coordinate System is `'
Metadata:
  HDFEOSVersion=HDFEOS_V2.6
  LOCALGRANULEID=MOD021KM.A2001140.0715.002.2001144040827.hdf
  PRODUCTIONDATETIME=2001-05-24T04:08:27.000Z
  DAYNIGHTFLAG=Day

... skipped ...

Subdatasets:
  SUBDATASET_1_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":2
  SUBDATASET_1_DESC=[15x408x271] EV_1KM_RefSB (16-bit unsigned integer)
  SUBDATASET_2_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":3
  SUBDATASET_2_DESC=[15x408x271] EV_1KM_RefSB_Uncert_Indexes (8-bit unsigned integer)
  SUBDATASET_3_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":4
  SUBDATASET_3_DESC=[16x408x271] EV_1KM_Emissive (16-bit unsigned integer)
  SUBDATASET_4_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":5
  SUBDATASET_4_DESC=[16x408x271] EV_1KM_Emissive_Uncert_Indexes (8-bit unsigned integer)
  SUBDATASET_5_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":6
  SUBDATASET_5_DESC=[2x408x271] EV_250_Aggr1km_RefSB (16-bit unsigned integer)
  SUBDATASET_6_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":7
  SUBDATASET_6_DESC=[2x408x271] EV_250_Aggr1km_RefSB_Uncert_Indexes (8-bit unsigned integer)
  SUBDATASET_7_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":8
  SUBDATASET_7_DESC=[2x408x271] EV_250_Aggr1km_RefSB_Samples_Used (8-bit integer)
  SUBDATASET_8_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":9
  SUBDATASET_8_DESC=[5x408x271] EV_500_Aggr1km_RefSB (16-bit unsigned integer)
  SUBDATASET_9_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":10
  SUBDATASET_9_DESC=[5x408x271] EV_500_Aggr1km_RefSB_Uncert_Indexes (8-bit unsigned integer)
  SUBDATASET_10_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":11
  SUBDATASET_10_DESC=[5x408x271] EV_500_Aggr1km_RefSB_Samples_Used (8-bit integer)
  SUBDATASET_11_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":19
  SUBDATASET_11_DESC=[408x271] EV_Band26 (16-bit unsigned integer)
  SUBDATASET_12_NAME=HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":20
  SUBDATASET_12_DESC=[408x271] EV_Band26_Uncert_Indexes (8-bit unsigned 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)

Corner coordinates are just a placeholders, don't pay attention on them.
Now you see how much GDAL supported subdatasets could be extracted from
the file and you can select the one. For example, take the first one,
described as "[15x408x271] EV_1KM_RefSB (16-bit unsigned integer)":

$ gdal_translate HDF4_SDS:MODIS_L1B:"MOD021KM.A2001140.0715.002.2001144040827.mimic.hdf":2 out.tif

Note, that resulting TIFF will have 15 bands and size 271x408.
Slightly complicated, but it is the only way to use non-interactive
tools.

					Regards,
					Andrey

-- 
Andrey V. Kiselev
Home phone:  +7 812 5274898  ICQ# 26871517



More information about the Gdal-dev mailing list