Sunday, 17 November 2019

pyqgis - Using processing.runalg in QGIS 3



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



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)

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...