Antonio, There are 2 issues : - the "ERROR 1: Corrupt or empty VRT source XML document." comes from the line 'b.SetMetadata(md, 'new_vrt_sources')'. However I'm not sure how to achieve what you want to do. I've the feeling you can't really define the pixel function that way. You should call GDALAddDerivedBandPixelFunc to do that, but as it is not available in Python bindings, I think you're only solution is to generate the whole XML at hand.
- the crash comes from the fact that you don't have defined a pixel function for the derived band. I've created ticket http://trac.osgeo.org/gdal/ticket/2877 about that one. Best regards, Even Le Sunday 08 March 2009 13:30:05 Antonio Valentino, vous avez écrit : > Il giorno Thu, 05 Mar 2009 09:26:51 -0500 > > Frank Warmerdam <warmer...@pobox.com> ha scritto: > > Antonio Valentino wrote: > > > Hi list, > > > I'm trying to create a *Derived* raster band in a virtual dataset. > > > > > > All my attempts seems to fail: > > >>>> ds.AddBand(options={'subClass': 'VRTDerivedRasterBand'}) > > > > > > raises an exception while > > > > > >>>> ds.AddBand(options='subClass="VRTDerivedRasterBand"') > > >>>> ds.AddBand(options=['subClass="VRTDerivedRasterBand"']) > > > > Antonio, > > > > I believe the correct syntax is: > > > > ds.AddBand(options=['subClass=VRTDerivedRasterBand']) > > > > The options should be a list of name=value pairs. Your extra double > > quotes within the string will make the class name comparison fail > > since you are effectively passing "\"VRTDerivedRasterBand\"" in C > > terms. > > > > Best regards, > > Hi Frank, > thanks for helping. > > I'm still having problems trying to create a derived raster bands via > python. > I'm using Ubuntu 8.10 > > $ uname -a > Linux mac1 2.6.27-13-generic #1 SMP Thu Feb 26 07:31:49 UTC 2009 x86_64 > GNU/Linux > > with GDAL 1.5.4 package from UbuntuGIS repo > (python-gdal_1.5.4-2~intreid3). > > The execution of the following test script produces a segmentation > fault: > > ### BEGIN CODE > from osgeo import gdal > driver = gdal.GetDriverByName('VRT') > source_xml = '''<SimpleSource> > <SourceFilename relativeToVRT="1">test.tif</SourceFilename> > </SimpleSource>''' > > md = {'Description': 'Magnitude', 'PixelFunctionType': 'module', > 'source_0': source_xml} > > ds = driver.Create('test.vrt', 100, 100) > b = ds.GetRasterBand(1) > b.SetMetadata({'source_0': source_xml}, 'new_vrt_sources') > ds.AddBand(options=['subClass=VRTDerivedRasterBand']) > b = ds.GetRasterBand(2) > b.SetMetadata(md, 'new_vrt_sources') > del ds > print open('test.vrt').read() > ### END CODE > > $ python test_derivedband.py > ERROR 1: Corrupt or empty VRT source XML document. > Segmentation fault > > > Maybe I'm still doing something wrong but the segfault is anomalous in > any case. > > Should I create a ticket for this? > > > Regards _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev