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

Martin Dobias wonder.sk at gmail.com
Sat Aug 7 11:10:24 EDT 2010


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