Bug report #21721
Disconnect between raster symbology in Layers Panel and Layer Properties
Status: | Open | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Rasters | ||
Affected QGIS version: | 3.4.6 | Regression?: | No |
Operating System: | Windows 7 | Easy fix?: | No |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 29536 |
Description
When using pyqgis to style raster layers, the layer properties symbology tab does not get updated with the information coming from python. If you run my sample python code below you will see the problem. The symbology is not consistent between the layers panel and the layer property symbology.
@from qgis.core import QgsRasterLayer
rlayer = QgsProject.instance().mapLayersByName('ac_filled_rvrem102')[0]
print (rlayer)
provider = rlayer.dataProvider()
stats = provider.bandStatistics(1, QgsRasterBandStats.All)
fcn = QgsColorRampShader()
fcn.setColorRampType(QgsColorRampShader.Interpolated)
lst = [ QgsColorRampShader.ColorRampItem(stats.minimumValue, QColor(247,251,255)),
QgsColorRampShader.ColorRampItem(stats.maximumValue, QColor(237,48,243)) ]
fcn.setColorRampItemList(lst)
shader = QgsRasterShader()
shader.setRasterShaderFunction(fcn)
renderer = QgsSingleBandPseudoColorRenderer(rlayer.dataProvider(), 1, shader)
rlayer.setRenderer(renderer)
rlayer.triggerRepaint()@
The page below also describes the issue
https://gis.stackexchange.com/questions/316450/disconnect-between-raster-symbology-in-layers-panel-and-layer-properties-qgis-3
I also updated to 3.4.6 and the same issue occurs.
History
#1 Updated by Giovanni Manghi over 5 years ago
- Affected QGIS version changed from 3.4.4 to 3.4.6