0

I have a QGIS project that displays calculation results on a map. There are several vector layers, each with >100 calculated fields. The way the data should be visualised is very similar for all these layers/fields. I try to write a script that duplicates a template layer, and changes the expressions for the symbology according to the selected fieldname.

Below is a screenshot of the properties I try to access (if I were to change them using the UI).

screenshot of the symbology properties I want to change, should I use the UI

How do I access/change the expressions of the line width and line offset of a graduated symbology in PyQGIS?

2 Answers2

0

In case someone else runs into this issue. I solved it using a workaround. I saved the style of the source layer to a qml-file, for the duplicated layers I create a temporary copy of the qml-file, do a search-and-replace on the qml-file and apply this to the new layer using newLayer.loadNamedStyle(pathToTheTempQmlFile)

0

Hope this helps:

rule=layer.renderer().rootRule().children()[0]
rule.setFilterExpression('whatever')

see: QgsRuleBasedRenderer.Rule

The Rabbit
  • 141
  • 5