[Qgis-developer] Pseudo-color raster drawing
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Tue Apr 24 13:04:01 EDT 2007
At last I've found something I can't do with a python plugin[1]...
I've got an ESRI grid file with integer values 1, 2, and 3. I want to
map this with specific colours for values 1, 2 and 3 (red, amber, green,
for example).
BUT I can't set a colour table for a QgsRasterLayer (the system gets
colour tables from the source, and this source doesn't have a colour
table palette)
AND since sometimes my grid might only have one or two of the values in
it, the pseudo colour drawing routine won't be consistent in its mapping
of values to colours
BUT I discovered I could use the grayscale mapping, and use
set{Min,Max}GrayDouble() to clamp the mapping of values to colours. I
could draw value 1 as white, value 2 as gray, value 3 as black.
BUT I don't want to use gray scales! Red is danger!
So I patched QgsRasterLayer.cpp so that if userDefinedGrayMinMax is set
then it maps the values to the pseudocolor palette using the set values.
Its about five lines.
Would this little patch be worth putting into Qgis? Or shall we wait
until someone has completely rewritten the raster table pseudo colour
mapping to be a bit more general and doesn't have 'FREAK_OUT' hard coded
into the C++...
Barry
[1] I tried making a new class that inherited from QgsRasterLayer, but
because the gdalDataset member is private I can't get to it from the
over-ridden 'draw' method!
More information about the Qgis-developer
mailing list