2

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
2
  • 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. – Ian Turton Sep 8 '20 at 14:32
  • 2
    What do you mean "nothing happened"? What do you expect? – Kadir Şahbaz Sep 8 '20 at 15:52
4

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.

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.