[Qgis-developer] How to load a colour table on a raster, programmatically (in python)?

Benoit de Cabissole benoit at exigesa.com
Sat Aug 7 11:38:43 EDT 2010


Hi Martin,

Haha!
Many thanks to have looked at that and fixed it.

Now, the bad news for me, I'm developping in Windows XP and the OSGeo4W
nightly builds (V1.6.x) need GDAL 1.7 to run but there is no python bindings
for that, at last as of yesterday, so most of the plugins do no work, I my
plugin also depends on GDAL...

So, standby for now.

Thanks again,
Benoit



> -----Original Message-----
> From: Martin Dobias [mailto:wonder.sk at gmail.com]
> Sent: Saturday, 07 August 2010 17:10
> To: benoit at exigesa.com
> Cc: qgis-developer at lists.osgeo.org
> Subject: Re: [Qgis-developer] How to load a colour table on a raster,
> programmatically (in python)?
>
>
> On Fri, Aug 6, 2010 at 2:43 PM, Benoit de Cabissole
> <benoit at exigesa.com> wrote:
> > I've tried many combinations around the following code:
> >
> > [...]
> > 129    theLayer.rasterShader().setRasterShaderFunction(
> > QgsColorRampShader() )
> > 130    theLayer.setRasterShaderFunction( QgsColorRampShader() )
> > 131    myColorRampShader = QgsColorRampShader()
> > 132    myColorRampShader.setColorRampItemList( theTBL )
> > 133    myColorRampShader.setMaximumColorCacheSize( nColo )
> > 134    myColorRampShader.setColorRampType( myColorRampShader.DISCRETE )
> > 135    theLayer.rasterShader().setRasterShaderFunction(
> myColorRampShader )
> > 136    theLayer.setRasterShaderFunction( myColorRampShader )
>
> Hi Benoit,
>
> I've took a look at the problem at it turned out there were actually
> two problems with python wrappers. I've fixed that in svn - r14022.
> From that revision, things should werk correctly. You should be able
> to either:
> - create an instance of shader function and assign it to raster layer
> without a crash
> - retrieve current raster shader function and modify it (previously
> always the base class QgsRasterShaderFunction was returned)
>
> Regards
> Martin



More information about the Qgis-developer mailing list