4

I am using QGIS 2.6.1-Brighton.

Can you find errors in my attempt to make Voronoi polygons using Python Console and suggest improvements?

I have tried the following scripts but got the errors.

output=processing.runalg("qgis:voronoipolygons",vlayer1, 0.000 ,"output_file.shp")

Nothing happened

import processing
output=processing.runalg("qgis:voronoipolygons",vlayer1,"output_file.shp")
Error: Wrong number of parameters
ALGORITHM: Voronoi polygons
 INPUT <parameters>
 BUFFER <parameters>
 OUTPUT <OutputVector>
output=processing.runalg("qgis:voronoipolygons",vlayer1,0.000%,"output_file.shp")
 File "<input>", line 1
 output=processing.runalg("qgis:voronoipolygons",vlayer1,0.000%,"output_file.shp")
^
SyntaxError: invalid syntax
Kadir Şahbaz
78.6k57 gold badges260 silver badges407 bronze badges
asked Sep 8, 2020 at 14:28
1
  • 2
    Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works. Commented Sep 8, 2020 at 14:32

1 Answer 1

6

Use full path for output. And I suggest you to use runandload method instead of runalg in this case. It adds the output to "Layers" panel.

import processing 
output = processing.runandload("qgis:voronoipolygons", vlayer1, 0, "C:/path/to/output.shp")
# or for temporary layer
output = processing.runandload("qgis:voronoipolygons", vlayer1, 0, None)

Please review QGIS 2 section in this answer.

answered Sep 8, 2020 at 16:20

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.