[Qgis-developer] color ramp shader in python

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Jan 22 08:03:13 EST 2009


2009/1/22 Volkan Kepoglu <vkepoglu at gmail.com>:
> i do not get what you mean, but you maybe try what i am using below
> python sample code in qgis 1.0 preview 2 for win.

 What I'm trying to do is control the mapping of values to colors -
for example I need 0.0 to be green, 0.5 to be white, and 1.0 to be
red, with smooth rgb transitions between. You can do this from the GUI
by going to the properties/symbology dialog and setting up a custom
colourmap. In the C++ API that uses QgsColorRampShader objects, which
don't seem to be available in the python bindings.

 What I'm giving the user is a way to load in these particular rasters
and then I have a menu of a small number of predefined colour schemes
that are appropriate to the data.

 I've currently worked round it by constructing a QDom document based
on what you get when you save the style from the symbology dialog,
inserting the color mapping that I need, and then using
layer.readSymbology.

Barry

PS aagh! I've started spelling 'colour' as 'color' :)


More information about the Qgis-developer mailing list