4

How can I modify this script in order to load .qml for all the raster (not vector in my case) files in the canvas?

layer = iface.activeLayer()

if layer.geometryType() == QGis.Point: # I need to change from vector to raster

    layer.loadNamedStyle('c:\\myQml.qml')
    layer.triggerRepaint()
4

I think the following should work:

for layer in QgsMapLayerRegistry.instance().mapLayers().values():
    if layer.type() == QgsMapLayer.RasterLayer:
        layer.loadNamedStyle('c:\\myQml.qml')
        layer.triggerRepaint()
  • @ilFonta - Most welcome, glad it worked :) – Joseph Aug 31 '17 at 10:27

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.