QGIS 3 Processing – Using processing.runalg

pyqgisqgis-3qgis-processing

I try to create a common extent for rasters in QGIS 2.99. Here is my script:

import processing

processing.runalg("script:unifyextentandresolution",
                  "/qgis_data/rasters/Image2.tif;
                  /qgis_data/rasters/Image1.tif",
                 -9999,"/qgis_data/rasters",True)

However, processing.runalg is being used for QGIS 2.99. I need it for QGIS 2.99

Best Answer

You need to use:

processing.run()

which is the equivalent to the QGIS <= 2.18 version:

processing.runalg()

I'm not sure how you created your input parameters in your script but I used the following dictionary format for a simple script (change the PARAMETER_X names with the ones you used:

import processing
parameters = {'PARAMETER_1': "/qgis_data/rasters/Image2.tif; /qgis_data/rasters/Image1.tif",
                'PARAMETER_2': -9999,
                'PARAMETER_3': "/qgis_data/rasters",
                'PARAMETER_4': True}

processing.run('script:unifyextentandresolution', parameters)
Related Question