In my plugin I would like to use the gdal tool "cliprasterbymask" and add the new clipped raster to my project.
According to the Documentation the output has the type "raster". So it returns a raster object.
Thus, I have tried the following:
clip = processing.run('gdal:cliprasterbymasklayer',{'INPUT': wasserstand,'MASK': gebeude,
'NODATA': -1, 'ALPHA_BAND': False, 'CROP_TO_CUTLINE': True, 'KEEP_RESOLUTION': True,
'OPTIONS': "", 'DATA_TYPE': 5, 'OUTPUT': outFile})
self.iface.addRasterLayer(clip)
Unfortunately, I get the following error message which I don't know what it means.
TypeError: QgisInterface.addRasterLayer(): arguments did not match any overloaded call: overload 1: argument 1 has unexpected type 'dict' overload 2: argument 1 has unexpected type 'dict'
How do I get the outputraster from cliprasterbymasklayer and what is actually output?
Apparently, its not just a simple raster layer.
OUTPUT
element of the dictionary returned by the processing algorithm. Assuming youroutFile
is a file path, the following should work:self.iface.addRasterLayer(clip['OUTPUT'], 'Clipped_raster')