2

I have two lists of raster (digital elevation model - DEM) layers by name. The first list of layers should be symbolized as follows: symbology should be set to hillshade layer rendering, blend mode should be set to soft light

enter image description here

and transparency, global opacity should be set to 30%

enter image description here

The second list of layers should be symbolized as follows: symbology should be set to singleband pseudocolor mode should be set to equal interval and classes should be set to 5

enter image description here

I want to apply all of these settings with PyQGIS code because I need to set them manually every single time.


I have managed to partially solve the aforementioned set of problems. The code for the first list of rasters (sets all the parameters properly):

`for i in list_1 :
    layer_1 = QgsProject.instance().mapLayersByName(i)[0]
    r = QgsHillshadeRenderer(layer_1.dataProvider(), 1, 315, 45)
    layer_1.setRenderer(r)
    layer_1.setBlendMode(QPainter.CompositionMode_SoftLight)
    layer_1.renderer().setOpacity(0.3)`

The code for the second list of rasters (only part of the solution):

`for i in list_2 :
    layer_2 = QgsProject.instance().mapLayersByName(i)[0]
    sbps = QgsSingleBandPseudoColorRenderer(layer_2.dataProvider(),1,)
    layer_2.setRenderer(sbps)`

How do I set Mode to Equal Interval and Classes to 5?

0

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.