[Qgis-developer] How do I use Python to generate a new Single Band Pseudo-Color color map for a single band raster?

thayeray thayeray at yahoo.com
Sun Apr 5 12:48:33 PDT 2015


This question has gone unanswered twice before (see below), so I am posting
it again:
Example 1
<http://osgeo-org.1560.x6.nabble.com/Re-Qgis-user-Digest-Vol-97-Issue-62-td5130720.html> 
, posted to the QGIS Developer list.
Example 2
<http://osgeo-org.1560.x6.nabble.com/Re-Qgis-user-Digest-Vol-97-Issue-62-td5130720.html>  
was posted to QGIS User, and directed to be posted on Developer (so I am
posting here).
I am trying to write a Python script that I can run which will adjust a
single band pseudo-color color map for a single band raster to the min and
max values in the current extent.
I have successfully added single band raster layers and set the drawing
style to single band pseudo color using the PyQGIS Developer Cookbook
instructions, with the following modification:
Instead of:
 
rlayer.setDrawingStyle(QgsRasterLayer.SingleBandPseudoColor)
I used:
rlayer.setDrawingStyle("SingleBandPseudoColor")
I have not been able to create a new color map, however. The Cookbook
suggests:
 rlayer.setColorShadingAlgorithm(QgsRasterLayer.PseudoColorShader)
Followed by making changes to rlayer's
rasterShader().rasterShaderFunction().
Apparently the RasterLayer class has changed and no longer possesses these
methods. There is a QgsColorRampShader class but I can not find a method
that takes a QgsRasterLayer object as a parameter or vice versa. 
The Detailed Description in the documentation for the QgsRasterLayer class
mentions a setStandardDeviations method for pseudocolor images, but I can
find any further reference to this method. This post
<http://gis.stackexchange.com/questions/92995/pyqgis-attributeerror-qgsrasterlayer-object-has-no-attribute-drawingstyle>  
on GIS stack exchange suggests a work around, applying a static QML style
file. I guess I could find the max and min values in the extents and then
output them to a QML style file and then load them, but that seems a little
contorted. Also I do not know how to get the min and max values in the
extents. Could someone at least help me with with that?Any thoughts?



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/How-do-I-use-Python-to-generate-a-new-Single-Band-Pseudo-Color-color-map-for-a-single-band-raster-tp5200024.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150405/b8fd6c70/attachment.html>


More information about the Qgis-developer mailing list