[Qgis-user] [pyQGIS] legend of QgsSingleBandPseudoColorRenderer
andrea antonello
andrea.antonello at gmail.com
Mon May 8 23:54:18 PDT 2023
Hello again,
I styled a raster using a colorramp like:
crsh = QgsColorRampShader()
crsh.setColorRampType(QgsColorRampShader.Interpolated)
lst = [
QgsColorRampShader.ColorRampItem(minV, QColor(255,0,0)),
QgsColorRampShader.ColorRampItem(minV + (maxV-minV)/2, QColor(0,255,0)),
QgsColorRampShader.ColorRampItem(maxV, QColor(0,0,255))
]
crsh.setColorRampItemList(lst)
shader = QgsRasterShader()
shader.setRasterShaderFunction(crsh)
renderer = QgsSingleBandPseudoColorRenderer(dtmLayer.dataProvider(), 1,
shader)
dtmLayer.setRenderer(renderer)
The raster shows up properly styled, but the legend is not handled
properly. Even if the minV and maxV are values between 800 and 2200, the
resulting legend is flat read and between 0 and 255:
[image: image.png]
Is there something I am doing wrong here?
Thanks,
Andrea
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230509/ff805c25/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 145935 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230509/ff805c25/attachment-0001.png>
More information about the QGIS-User
mailing list