1

I'm facing a very strange issue from the module Processing using it as a standalone (not in the Qgis python console). I'm trying to create voronoi polygons from a points csv file. I can load my file without issue but the Processing.runAlgorithm always fail with " wrong number of arguments ". There are only 3 arguments described in the help.

#create uri
uri = "file://{}?delimiter={}&xField={}&yField={}".format(os.path.abspath(fichier.name),",","x","y")
#open file
layer = QgsVectorLayer(uri, "tmp", "delimitedtext")
# check
if not layer.isValid():
 print "Layer didn't load properly."
 print "Check your filename and the file integrity."
# UTF-8
layer.setProviderEncoding('UTF-8')
#feedback
print("File successfully loaded as " + layer.name() + " layer.")
Processing.runAlgorithm("qgis:voronoipolygons",layer,0.0, "test2.shp")

Traceback :

File successfully loaded as tmp layer.
Error: Wrong number of parameters
ALGORITHM: Voronoi polygons
 INPUT <ParameterVector>
 BUFFER <ParameterNumber>
 OUTPUT <OutputVector>

but it works from the Qgis python console :

mapcanvas = iface.mapCanvas()
layers = mapcanvas.layers()
processing.runalg("qgis:voronoipolygons",layers[0],0.0,"test.shp")

Output :

{'OUTPUT': 'test.shp'}

Even stranger, when i'm trying to add an unknown argument like :

Processing.runAlgorithm("qgis:voronoipolygons",layer,0.0, "test2.shp",0.0)

it returns :

File successfully loaded as tmp layer.
Error: Wrong parameter value: test2.shp

With adding 2 unknown arguments :

Processing.runAlgorithm("qgis:voronoipolygons",layer,0.0, "test2.shp",0.0,0.0)

TB :

File successfully loaded as tmp layer.
Error: Wrong number of parameters
ALGORITHM: Voronoi polygons
 INPUT <ParameterVector>
 BUFFER <ParameterNumber>
 OUTPUT <OutputVector>

Looks like there is a forth argument ... Any idea ?

BritishSteel
6,7174 gold badges41 silver badges66 bronze badges
asked Jun 6, 2016 at 16:49

1 Answer 1

1

Syntax is:

runAlgorithm(algOrName, onFinish, *args, **kwargs). 

Just set None to onFinish argument.

John Powell
13.7k5 gold badges49 silver badges62 bronze badges
answered Jun 7, 2016 at 10:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.