2

For my script i want to update the existing colourramp of a raster with new min and max value. In my current code is can fill the min and max but can't classify and update the raster.

How does the classify button works to classifies colours with the new min and max values.

My current code is:

rLayer = iface.activeLayer()
provider = rLayer.dataProvider()
stats = provider.bandStatistics(1, QgsRasterBandStats.All, rLayer.extent())

min = 2
max = 5

rLayer.renderer().setClassificationMin(min)
rLayer.renderer().setClassificationMax(max)

This result in the following image: enter image description here

as you can see the new min and max is filled but the colour ramp isn't classified. I hope there is generic code to fill the colours with their new min and max because the chosen colourramp is variabel.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.