3

How to apply a SLD file to a layer in QGIS from the QGIS console?

I tried this but it didn't work:

# selecting the layer
layer = iface.activeLayer()
# Apply SLD on the layer
layer.loadSldStyle("mystyle.sld")

It doesn't give a error. But I also don't get a result.

1
  • The code was indeed correct; I had to refresh the layer to see the changes.
    – Saxoriko
    Commented Jan 27, 2016 at 15:45

1 Answer 1

2

The code was correct; I had to refresh the layer:

layer.triggerRepaint()

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.