[gdal-dev] Amplitude virtual bands for complex datasets ?

Even Rouault even.rouault at spatialys.com
Wed Jul 6 01:26:50 PDT 2016

> Even, I think the AddBand() method is obviously not the right place to
> do that, but I do not get how tweak the GetMetadata() /
> GetMetadataDomainList().

Hum I'm not sure how to better explain. I almost coded it ;-)

> As far as I can tell from the code, datasets
> never directly declare new domains by hacking GetMetadataDomainList().
> Calling SetMetadataItem() with a new domain is enough to create it (that
> is what I did). But I surely miss something here.

We definitely don't want to call SetMetadata() / SetMetadataItem() in generic 
code, as it could have a lot of undesired side effects, like pushing metadata 
to PAM (.aux.xml files) or to the own metadata storage of the driver. IMHO, the 
derived subdataset reporting must rather be done in a "passive" way with 

Hum, after all, maybe SetBand() could still do it, but we would need to make 
sure to explicitly call GDALDataset::SetMetadataItem(), and not the potential 
overridden SetMetadataItem() method of a driver.

> Also, can we discuss syntax (COMPLEX_AMPLITUDE is not very meaningful)
> and behaviour (for now all bands are considered even if they are not
> complex).
> Last, it does not work for real subdatasets. For instance, for S2 data :
> $ gdalinfo -mdd DERIVED_SUBDATASETS
> SENTINEL2_L1C:S2A_OPER_MTD_SAFL1C_PDMC_20150519T113602_R070_V20130707T17215
> 6_20130707T172156.xml:20m:EPSG_32615
> Driver: SENTINEL2/Sentinel 2
> [...]
>    DERIVED_SUBDATASET_1_DESC=Complex amplitude of bands from
> [...]

Probably because at the time of SetBand(), the dataset name hasn't been set 
yet on the dataset object. It is generally done at the very end of the Open() 
method, and that's the case of the Sentinel2 driver, and most all other 
drivers that are generally copied&pasted from the same skeleton. So the 
SetBand() way seems to be a dead end, unless we edit all drivers (probably not 
all drivers, just in drivers that can have complex data types) to initialize 
their description earlier. 


Spatialys - Geospatial professional services

More information about the gdal-dev mailing list