3

I have a similar question as @drnextgis in this post: I made a change to the symbol colour of one value out of four categorised values and aim to automatically apply it to other layers in the same QGIS project using the same symbology of the same .qml.

I'm working in one QGIS project with about 40 layers (landparcels, 1.8 GB in total) that all have the same attributes and therefore share the same .qml-file. The .qml-file is set as default for each layer. If I change the symbol colour of a value in one of the 40 layers and select 'Save Style...' and then overwrite the existing .qml, the change only applies to this particular layer. It neither makes a difference if I select 'Save as Default'.

Checking out related posts: This question is talking about a .qml which is used in several projects and this one is about layers having the same name but I don't think they cover my issue.

I use the LTR version of QGIS (3.10.9.).

2
  • Styles are primarily saved in the QGIS project itself. I guess you could force a reload of certain styles from the .qml on opening the project. Or you could merge all layers into one? Or build a virtual layer which contains all parcels. – Erik Sep 11 '20 at 13:26
  • Thank you, Erik. Do you mean a different reload than using the Refresh button (F5)? Merging is not an option really because of performance implications in the related web application. – Aron Sep 11 '20 at 14:08
1

If the symbology you want to change is only found in the layers you want to change, then you could consider opening the project file in a text editor and doing a find and replace i.e. change the colour from for example <prop k="color" v="255,0,0,255"/>
to <prop k="color" v="0,0,255,255"/> Which changes all instances of red to blue. (the qgz project file is a zip file and contains 2 files as a minimum - your actual project file with the extension .qgs and .qgd file.) This is a suggested set of steps;

  1. Take a backup of your project file (.qgz)
  2. Rename the project file to filename.zip
  3. Extract the .qgs file from the zip file
  4. Open the .qgs file in a text editor.
  5. Do a text search for one of the layers - scroll down to find its symbology.
  6. Do a search for the text you want to change - if there are the same number of occurrences of this text (i.e.the symbol colour)as layers - you can do a global find and replace. Otherwise you may have to step through each one - or do all and go back and change those that should not have been changed.
  7. Save the .qgs file
  8. Move the .qgs file back into the .qgz file.
  9. Open the .qgz file in QGIS.
  10. Last thing to do is make the change in the qml files - you could do a batch replace as outlined in this post (many different ways of doing it)
0

I have a similar problem. For me the solution in this thread is promising, I have yet to try it though:

Answer: "You can try use Set style for vector layer algorithm."

Auto-Styling QGIS vector layers symbology

1
  • I now found out, that this does not link the Style file permanently to a layer and so does not update the style when changed..... so that is no solution. – Nightflight Sep 25 '20 at 14:41
0

This isn't a perfect solution (because it is not automatic) but it is a very useful feature which I only discovered a short while ago after coming across the same issue you are having. When you copy the style of a layer by right clicking > Styles > Copy Style you can then paste the style onto multiple layers by Shift + Left Click on all the relevant layers in the layers panel the right clicking > Paste Style. This will then be applied to them all.

If the layers are all together in the layers panel then you can just hold Shift and click the top and then bottom layer to highlight them all.

enter image description here

0

Another thing I found is a plugin called "Layer Style Loader":

https://plugins.qgis.org/plugins/LayerStyleLoader/

Although not too comfortable since the layer and the qml have to have the same name, this could finally be the solution. Unfortunately it seems the plugin cannot be loaded in QGIS 3.x :(

Is there a way it can be loaded?

Your Answer

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

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