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()
Joseph
76.7k8 gold badges173 silver badges286 bronze badges
asked Aug 31, 2017 at 10:17
1 Answer 1
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()
answered Aug 31, 2017 at 10:21
-
@ilFonta - Most welcome, glad it worked :)Joseph– Joseph2017年08月31日 10:27:07 +00:00Commented Aug 31, 2017 at 10:27
lang-py