0

I'm approaching naw in the script and I'm trying to select many multi-band files from a folder and extract a single band from the file, putting everything in an output folder with the single-band transformed files.

Currently I concluded the following script:

 import sys, os

 output = "C:/../folder"

 layers =[layer for layer in QgsProject.instance().mapLayers().values()]


 for lyr in layers:
    if (lyr.type()==QgsMapLayer.RasterLayer): 

    cmd1 = "gdal_translate -b 1 "+ lyr.source() + "C:/..raster_input" + outputDir + "C:\..output" + lyr.name() + "test.ecw" 

    os.system(cmd1)

    cmd2 = outputDir + "C:\..output" + lyr.name() + "test.ecw"

    iface.addRasterLayer(cmd2)

But it does not work!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.