I have many raster layers in my QGIS project and they're all currently rendered as: Multiband color Red band: Band 1 Green band: Band 2 Blue band: Band 3

I'd like to know if there's any way I can change the rendering of all raster layers to: Red band: Band 3 Green band: Band 2 Blue band: Band 1 without having to do it by hand, layer by layer.

2 Answers 2


You can use pyqgis. This will change symbology of all raster layers in layer tree to red band=band 3, green=band 2, blue=band 1:

for lyr in QgsProject.instance().mapLayers().values():
    if isinstance(lyr, qgis.core.QgsRasterLayer): #Check to make sure it is a raster layer
        r = lyr.renderer().clone()

enter image description here

  • I'm sorry to bother you, but I've ran into some trouble. The bands change accordingly, but the changes don't apply unless I go into each layer's symbology and hit the "Apply" button. I tried using triggerRepaint() and other similar methods like qgis.utils.iface.mapCanvas().refresh() but they don't seem to work. Any help?
    – willsbit
    Aug 17, 2020 at 2:22
  • Try now, I've changed the code!
    – BERA
    Aug 17, 2020 at 6:19
  • The same thing still happens. I think it has something to do with applying the "stretch to min-max" contrast settings. I tried working around it with something like this: layer = iface.activeLayer() contrastFilter = QgsBrightnessContrastFilter() contrastFilter.setContrast(50) layer.pipe().set(contrastFilter) layer.triggerRepaint() but it basically does nothing
    – willsbit
    Aug 17, 2020 at 13:18

Set it up for one layer.

Right click that layer, Styles -> Copy Style.

Select all the other layers you want to apply the same style to, right-click, Styles -> Paste Style.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.