pythonqgissldpyqgis

Exporting sld with pyQgis


Is there a way to export the style of a layer thanks to pyqgis in a sld file?
I didn't find it in the documentation. I am in a 3.x version of Qgis


Solution

  • You can use QgsMapLayer::saveSldStyle to export layer style as SLD.

    layer = iface.addVectorLayer('C:/example.shp', 'mylayer', 'ogr')
    layer.saveSldStyle('C:/Styles/SLD/layer_style.sld')