How can I solve the problem shown below:

error message

I am trying to build a plugin that allows me to resample the raster data to any desired resolution of my choice with 20 being the minimum input value, as shown below:


Here is my code:

# Get layer object 
fn = 'output1' # where output1 is an output of a just created layer in an excuted action above 
# rlayer = iface.addRasterLayer(fn)
rlayer = QgsRasterLayer(fn, '')
ras_out = rlayer

processing.run('saga:resampling', ras_out, True, 1, 1, [], 1, output2)
  • 2
    Please do not use ALL CAPS for question titles. "Shouting" is likely to generate downvotes. – Vince Oct 27 at 16:40
  • thanks@Vince. I am looking forward to receiving any assistance with my question. Thank you. – De Falasy Oct 27 at 17:02

As the error says processing.run() only takes two arguments. The first should be the name of the algorithm, so you've got that part right. The second is a dictionary of any additional parameters. So instead of:

processing.run('saga:resampling', ras_out, True, 1, 1, [], 1, output2)

you would need something like :

processing.run('saga:resampling', {"PARAM_NAME" : ras_out, 
                                   "PARAM_NAME" : True, 
                                   "PARAM_NAME" : 1, 
                                   "PARAM_NAME" : 1, 
                                   "PARAM_NAME" : [], 
                                   "PARAM_NAME" : 1, 
                                   "PARAM_NAME" : output2})

Note that "PARAM_NAME" is just a place holder ... you can look up actualy parameter names with processing.algorithmHelp('saga:resampling')

| improve this answer | |
  • Thank you. It helped alot. – De Falasy Nov 1 at 3:06

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.