I'm trying to use gdal_translate tool in a python script I'm writing in QGIS 2.18.3. I use the translate tool because I want to change all the zero values (in all 8 bands of my raster) to nodata. I'm able to do so manually by using the tool from the toolbox. When I run my code in QGIS script editor the processing window disappear after a second, I don't get any error message but no new file is created. I think it is something to do with how this tool understands what is raster, but I've successfully used other gdal tools (merge, raster calculator) in python script using the same method, so I don't understand why it does not work in the translate tool.
This is a simple code I'm trying to use:
##last_try=name ##Select_directory=Folder import glob, os from PyQt4.QtCore import QFileInfo from qgis.core import * for raster in glob.glob("*.tif"): fileInfo = QFileInfo(raster) baseName = fileInfo.baseName() rlayer = QgsRasterLayer(raster, baseName) trans = os.path.join(Select_directory,"image_suffix.tif") outputs_GDALOGRTRANSLATE_1=processing.runalg('gdalogr:translate', rlayer,100.0,True,'0',0,'',None,False,5,4,75.0,6.0,1.0,False,0,False,None,trans)
As I mentioned, this type of code works great with other gdal tools.
What's wrong with my code?