1

I am trying to apply a .qml style from QGIS to each individual .tif image, contained within a folder, using python, but I can't get it to work. Is there a way to do this without loading the images into QGIS?

Here is my code which isn't working:

import glob     
for layers in glob.glob('E:/Clipped/*.tif'):        
    layers.loadNamedStyle('E:/style.qml')
  • 1
    What is the point of styling layers without loading them? – underdark Feb 22 '18 at 18:54
  • I am wanting the final rendered .tif files so I can load them into a report. If there is away to load the images into QGIS and apply the style then save them out as rendered images all via a python scrit then this would work too but I'm struggling to load all .tifs at once with a script. – user8136435 Feb 22 '18 at 22:01

1 Answers1

1

You need to load each raster into the canvas, apply the qml file and then export back to a pdf/jpg/tiff etc. Create a template using print composer and then take a look at this blog post and this question for some idea on how to code the export.

firefly-orange
  • 2,521
  • 6
  • 23