[Qgis-user] Re: [gdal-dev] Problems with gdal and hdf files

Etienne Tourigny etourigny.dev at gmail.com
Wed May 2 06:04:24 PDT 2012


On Wed, May 2, 2012 at 9:43 AM, Agustin Lobo <alobolistas at gmail.com> wrote:
> You are right. I was confusing bands and subdatasets.
> The following does not work:
> $ gdal_translate -b 4  lndsr.L5169054_05420101216.hdf test.tif
> Input file contains subdatasets. Please, select one of them for reading.
>
> The following works:
> $ gdal_translate -sds lndsr.L5169054_05420101216.hdf test.tif
> which results in test.tif1 to test.tif9 (probably should be test1.tif
> to test9.tif)
>
> but there is no way to actually select 1 or more specific subdatasets

same thing if you use the extended file syntax (e.g.
HDF4_EOS:EOS_GRID:"lndsr.L5169054_05420101216.hdf":Grid:band1 ) .

You can probably work around this limitation by creating a vrt file
with gdalbuildvrt

>
> The most important
> QGIS complains:
> Cannot get GDAL raster band:
>
> R (raster) complains
>> r <- brick("lndsr.L5169054_05420101216.hdf")
> Error in .rasterObjectFromFile(x, objecttype = "RasterBrick", ...) :
>  Cannot create a RasterLayer object from this file.
> In addition: Warning message:
> In .rasterFromGDAL(x, band = band, objecttype, ...) :
>  GeoTransform values not available; georeferencing will not be correct
>>

pass the vrt file you created to R, it should work as long as gdalinfo
works on that vrt file, although I have never tried it.

>
> but GDALinfo() is correct.
> Cannot test hdf5 or readGDAL() in R as the file is huge
>
> I guess the problem is in QGIS (and R package raster)? I'm not sure,
> as I do not know if
> subdatasets can be selected for reading using gdal.

Also see if you can load the vrt file in qgis!

>
> Agus
>
> 2012/5/2 Even Rouault <even.rouault at mines-paris.org>:
>> Selon Agustin Lobo <alobolistas at gmail.com>:
>>
>>> Hi!
>>>
>>> The gdal info of a multiband satellite image in hdf is reported by
>>> gdal as "Size is 512, 512"
>>> in contradiction with the size of the subdatasets. QGIS and R
>>> (raster+rgdal) report an error at opening the file,
>>> while envi and HDFLook can open it with no problem. I include the
>>> gdalinfo output and the
>>> info reported by HDFLook. Any help appreciated.
>>
>> I don't consider that to be a problem. The size reported on a GDAL dataset that
>> is only made of subdatasets (that is to say when the dataset has no raster bands
>> in itself, which is the case here) has no meaning, and is put to a default value
>> of 512x512. You have to open the subdatasets to know their size(in the case of
>> HDF4, the description of the subdataset also give them). There are cases where
>> the subdsatasets have different sizes, so it would be impossible to set a
>> significant value for the size of the dataset.
>>
>>> Thanks
>>> Agus
>>>
>>> $ gdalinfo --version
>>> GDAL 1.8.0, released 2011/01/12
>>>
>>> $ gdalinfo lndsr.L5169054_05420101216.hdf
>>> Driver: HDF4/Hierarchical Data Format Release 4
>>> Files: lndsr.L5169054_05420101216.hdf
>>> Size is 512, 512
>>> Coordinate System is `'
>>> Metadata:
>>>   DataProvider=UMD
>>>   Satellite=LANDSAT_5
>>>   Instrument=TM
>>>   AcquisitionDate=2010-12-16T00:00:00.000000Z
>>>   Level1ProductionDate=2012-02-22T00:00:00.000000Z
>>>   SolarZenith=42.02009
>>>   SolarAzimuth=141.4236
>>>   WRS_System=2
>>>   WRS_Path=169
>>>   WRS_Row=54
>>>   NumberOfBands=6
>>>   BandNumbers=1, 2, 3, 4, 5, 7
>>>   ShortName=L5TSR
>>>   LocalGranuleID=L5TSR.a2010350.w2p169r054.020.2012117105207.hdf
>>>   ProductionDate=2012-04-26T10:52:07Z
>>>   PGEVersion=1.0.9
>>>   ProcessVersion=1.0.4
>>>   WestBoundingCoordinate=36.6199876177544
>>>   EastBoundingCoordinate=38.780676500528
>>>   NorthBoundingCoordinate=9.61826703329522
>>>   SouthBoundingCoordinate=7.72285510894074
>>>   OrientationAngle=0
>>>   PixelSize=30
>>>   HDFEOSVersion=HDFEOS_V2.4
>>>   Cloud Mask Algo Version=CMReflectanceBasedv1.0
>>> Subdatasets:
>>>
>>>
>> SUBDATASET_1_NAME=HDF4_EOS:EOS_GRID:"lndsr.L5169054_05420101216.hdf":Grid:band1
>>>   SUBDATASET_1_DESC=[6961x7901] band1 Grid (16-bit integer)
>>>
>>>
>> SUBDATASET_2_NAME=HDF4_EOS:EOS_GRID:"lndsr.L5169054_05420101216.hdf":Grid:band2
>>>   SUBDATASET_2_DESC=[6961x7901] band2 Grid (16-bit integer)
>>>
>>>
>> SUBDATASET_3_NAME=HDF4_EOS:EOS_GRID:"lndsr.L5169054_05420101216.hdf":Grid:band3
>>>   SUBDATASET_3_DESC=[6961x7901] band3 Grid (16-bit integer)
>>>
>>>
>> SUBDATASET_4_NAME=HDF4_EOS:EOS_GRID:"lndsr.L5169054_05420101216.hdf":Grid:band4
>>>   SUBDATASET_4_DESC=[6961x7901] band4 Grid (16-bit integer)
>>>
>>>
>> SUBDATASET_5_NAME=HDF4_EOS:EOS_GRID:"lndsr.L5169054_05420101216.hdf":Grid:band5
>>>   SUBDATASET_5_DESC=[6961x7901] band5 Grid (16-bit integer)
>>>
>>>
>> SUBDATASET_6_NAME=HDF4_EOS:EOS_GRID:"lndsr.L5169054_05420101216.hdf":Grid:band7
>>>   SUBDATASET_6_DESC=[6961x7901] band7 Grid (16-bit integer)
>>>
>>>
>> SUBDATASET_7_NAME=HDF4_EOS:EOS_GRID:"lndsr.L5169054_05420101216.hdf":Grid:atmos_opacity
>>>   SUBDATASET_7_DESC=[6961x7901] atmos_opacity Grid (16-bit integer)
>>>
>>>
>> SUBDATASET_8_NAME=HDF4_EOS:EOS_GRID:"lndsr.L5169054_05420101216.hdf":Grid:lndsr_QA
>>>   SUBDATASET_8_DESC=[6961x7901] lndsr_QA Grid (16-bit integer)
>>>
>>>
>> SUBDATASET_9_NAME=HDF4_EOS:EOS_GRID:"lndsr.L5169054_05420101216.hdf":Grid:band6
>>>   SUBDATASET_9_DESC=[6961x7901] band6 Grid (16-bit 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)
>>>
>>>
>>> HDFLooK:
>>>
>>> Global attributes: 26
>>> DataProvider:
>>>
>> UMDLANDSAT_5TM2010-12-16T00:00:00.000000Z2012-02-22T00:00:00.000000Z    SolarZenith:    42.0201
>>>       SolarAzimuth:   141.424
>>> 2     WRS_Path:       169
>>>       WRS_Row:        54
>>>       NumberOfBands:  6
>>>       BandNumbers:    1,  2,  3,  4,  5,  7
>>>
>> L5TSRL5TSR.a2010350.w2p169r054.020.2012117105207.hdf2012-04-26T10:52:07Z1.0.91.0.4      WestBoundingCoordinate: 36.62
>>>       EastBoundingCoordinate: 38.7807
>>>       NorthBoundingCoordinate:        9.61827
>>>       SouthBoundingCoordinate:        7.72286
>>>       OrientationAngle:       0
>>>       PixelSize:      30
>>>
>> HDFEOS_V2.4-----------------------------------------------------------------------------------
>>> GROUP=SwathStructure
>>> END_GROUP=SwathStructure
>>> GROUP=GridStructure
>>>       GROUP=GRID_1
>>>               GridName="Grid"
>>>               XDim=7901
>>>               YDim=6961
>>>               UpperLeftPointMtrs=(238785.000000,1063215.000000)
>>>               LowerRightMtrs=(475815.000000,854385.000000)
>>>               Projection=GCTP_UTM
>>>               ZoneCode=37
>>>               SphereCode=12
>>>               GridOrigin=HDFE_GD_UL
>>>               GROUP=Dimension
>>>               END_GROUP=Dimension
>>>               GROUP=DataField
>>>                       OBJECT=DataField_0
>>>                               DataFieldName="band1"
>>>                               DataType=DFNT_INT16
>>>                               DimList=("YDim","XDim")
>>>                       END_OBJECT=DataField_0
>>>                       OBJECT=DataField_1
>>>                               DataFieldName="band2"
>>>                               DataType=DFNT_INT16
>>>                               DimList=("YDim","XDim")
>>>                       END_OBJECT=DataField_1
>>>                       OBJECT=DataField_2
>>>                               DataFieldName="band3"
>>>                               DataType=DFNT_INT16
>>>                               DimList=("YDim","XDim")
>>>                       END_OBJECT=DataField_2
>>>                       OBJECT=DataField_3
>>>                               DataFieldName="band4"
>>>                               DataType=DFNT_INT16
>>>                               DimList=("YDim","XDim")
>>>                       END_OBJECT=DataField_3
>>>                       OBJECT=DataField_4
>>>                               DataFieldName="band5"
>>>                               DataType=DFNT_INT16
>>>                               DimList=("YDim","XDim")
>>>                       END_OBJECT=DataField_4
>>>                       OBJECT=DataField_5
>>>                               DataFieldName="band7"
>>>                               DataType=DFNT_INT16
>>>                               DimList=("YDim","XDim")
>>>                       END_OBJECT=DataField_5
>>>                       OBJECT=DataField_6
>>>                               DataFieldName="atmos_opacity"
>>>                               DataType=DFNT_INT16
>>>                               DimList=("YDim","XDim")
>>>                       END_OBJECT=DataField_6
>>>                       OBJECT=DataField_7
>>>                               DataFieldName="lndsr_QA"
>>>                               DataType=DFNT_INT16
>>>                               DimList=("YDim","XDim")
>>>                       END_OBJECT=DataField_7
>>>                       OBJECT=DataField_9
>>>                               DataFieldName="band6"
>>>                               DataType=DFNT_INT16
>>>                               DimList=("YDim","XDim")
>>>                       END_OBJECT=DataField_9
>>>               END_GROUP=DataField
>>>               GROUP=MergedFields
>>>               END_GROUP=MergedFields
>>>       END_GROUP=GRID_1
>>> END_GROUP=GridStructure
>>> GROUP=PointStructure
>>> END_GROUP=PointStructure
>>> END
>>>
>> -----------------------------------------------------------------------------------
>>> CMReflectanceBasedv1.0
>>> _______________________________________________
>>> gdal-dev mailing list
>>> gdal-dev at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>>
>>
>>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user



More information about the Qgis-user mailing list