52

I'm working on bulk data. I have a few hundred GeoTIFF images imported into a QGIS project, and I'd like to modify their layer properties - things like the no-data-value, transparency of certain pixel values, colour map assignments...

But I can't seem to find a way to apply these changes to several layers at once, short of editing the XML file with a global search-and-replace. Is there a way to do this using the GUI?

0

5 Answers 5

57

In current versions of QGIS, you can use Copy Style and then Paste Style from the Layers top dropdown menu (if you have one or more layers selected in the layers list).


For some older versions: You can select multiple layers in the layers list, right-click and use Paste Style from the context menu.

For other older versions:

The MultiQML plugin lets you apply one QGIS layer style to multiple layers at once. I think that's as close to what you are looking for as currently possible.

1
  • 1
    Does not work for me on QGIS 3.10, Paste Style only pastes the style to the last layer in the selection. Grouping from GISinHelsinki's answer does.
    – Dahn
    Commented Dec 4, 2020 at 8:01
47

This works for QGIS 3.4 =>

  1. Create a group of all the layers you want to have the same style
  2. Edit the style of one of the layers in the group to your liking
  3. Right-click the correctly styled layer; 'Styles' -> 'Copy Style' -> 'Symbology'
  4. Select the group you created before
  5. Right-click the group; 'Paste Style'
6
  • 3
    This needs to be the accepted answer, it's quick and it's easy and it just works... without any complicated plug in madness.
    – shawty
    Commented Nov 28, 2019 at 19:07
  • 'Paste Style' not available for group context menu in QGIS 3.16. Eventually I just merged vector layers (gis.stackexchange.com/questions/25061/…) and modified the style of the resulting layer.
    – Sussch
    Commented Dec 9, 2020 at 8:30
  • 'Paste Style' is available for group context in QGIS 3.16.2.
    – pathmapper
    Commented Jan 19, 2021 at 15:46
  • But this option (Paste Style in Group context menu) has gone missing again? Certainly not visible in 3.16.16 Hanover...?
    – Sharad
    Commented Apr 16, 2023 at 9:17
  • 1
    Seems to play hide & seek: I´m running 3.22.13 and 3.28.1 and the 'Paste Style' option for a group works in both. Commented Apr 17, 2023 at 12:11
8

If you save the style options for the one vector layer as a .qml file, you can apply it onto multiple layers at once with the MultiQML-plugin. Basically, it's an interface window that lets you select which layers you want the style to apply to (by hand, or 'select all'), the 'apply style' button lets you select the qml with the style info.

Info to be found here: MultiQML

1

You can save your project, close QGIS, find the style definition in the .qgs file of your project then paste it for every layers.

0
1

I wrote a python script that could be useful if you want to apply style to all layers in a group or more. All you need to have is a saved .qml file with the properties you want to apply for each type of layer.

from qgis.core import *
import os
#copy line 9-21 and change file names and group names if you have more groups

QML_file = ('yourqmlfile.qml')#insert path to qml file 
#add other qml files if you want to change style for more groups


def applystyle_group(name):
    root = QgsProject.instance().layerTreeRoot()
    point = root.findGroup(name) #Find Group
    for child in point.children():
        if isinstance(child, QgsLayerTreeLayer):
            if child.layer().type()==0:
                child.layer().loadNamedStyle(QML_file)#change the file name accordingly
                #you can add styles for other types of layers in the same group (line, point and polygon)

try: #If group is not present this will keep script running if you want to add more
    applystyle_group("*")#insert name of QGIS group
except Exception:
    pass

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.