Opened 14 years ago

Closed 14 years ago

#3589 closed defect (fixed)

SetDescription method needs to be overridden in VRTRasterBand

Reported by: fasano Owned by: warmerdam
Priority: normal Milestone: 1.8.0
Component: default Version: unspecified
Severity: normal Keywords:
Cc: antonio

Description

SetDescription method needs to be overridden in VRTRasterBand. So it will be possible to flush it so that any change of the "Description" item is written on disk.

In fact at the moment if this item is changed on the object, this change is not written on the file. See following example:

from osgeo import gdal

realfname = 'image.tiff'
vrtfilename = 'vrtdataset.vrt'

#open real dataset and create copy as a vrt file
vrt_driver = gdal.GetDriverByName('VRT')
gtiff_driver = gdal.GetDriverByName('GTIFF')

realdataset = gtiff_driver.Create(
            'image.tiff', 100, 100, 1, eType=gdal.GetDataTypeByName('Byte'))
vrtdataset = vrt_driver.CreateCopy(vrtfilename, realdataset)
vrtband = vrtdataset.GetRasterBand(1)

#try to modify Description
print 'Band description before change is:', vrtband.GetDescription()
vrtband.SetDescription('New Description for band')
print 'Band description after change is:', vrtband.GetDescription()
print

del vrtband, vrtdataset, realdataset

Executing the script the output is:

fasano@fasano-debian:~/Desktop/test$ python gdalvrt2.py 
Band description before change is: 
Band description after change is: New Description for band

But the result is:

fasano@fasano-debian:~/Desktop/test$ cat vrtdataset.vrt
<VRTDataset rasterXSize="100" rasterYSize="100">
  <Metadata/>
  <VRTRasterBand dataType="Byte" band="1">
    <Metadata/>
    <ColorInterp>Gray</ColorInterp>
    <SimpleSource>
      <SourceFilename relativeToVRT="1">image.tiff</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="100" RasterYSize="100" DataType="Byte" BlockXSize="100" BlockYSize="81"/>
      <SrcRect xOff="0" yOff="0" xSize="100" ySize="100"/>
      <DstRect xOff="0" yOff="0" xSize="100" ySize="100"/>
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>

Note that no "Description" field is in file.

See #3588 too.

Change History (2)

comment:1 by antonio, 14 years ago

Cc: antonio added

comment:2 by Even Rouault, 14 years ago

Milestone: 1.8.0
Resolution: fixed
Status: newclosed

Fixed in trunk in r19814

Note: See TracTickets for help on using tickets.