I'm trying to update a single band psuedo color renderer with new min/max values from the python console. All the code samples i have been able to find deal with constructing a renderer from scratch, but in this case I have a color ramp setup for an existing layer and I want to be able to stretch to color ramp with new min/max values.
I can set the new min/max values for the renderer, i just haven't figured out how to reclassify the color ramp(I'm looking for the equivalent of hitting the "classify" button in the style properties dialog).
This is what I have so far:
l = iface.activeLayer()provider = l.dataProvider()extent = canvas.extent()stats = provider.bandStatistics(1, QgsRasterBandStats.All, extent)min = stats.minimumValuemax = stats.maximumValuel.renderer().setClassificationMin(min)l.renderer().setClassificationMax(max)
أكثر...
I can set the new min/max values for the renderer, i just haven't figured out how to reclassify the color ramp(I'm looking for the equivalent of hitting the "classify" button in the style properties dialog).
This is what I have so far:
l = iface.activeLayer()provider = l.dataProvider()extent = canvas.extent()stats = provider.bandStatistics(1, QgsRasterBandStats.All, extent)min = stats.minimumValuemax = stats.maximumValuel.renderer().setClassificationMin(min)l.renderer().setClassificationMax(max)
أكثر...