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
  • 76,800
  • 56
  • 247
  • 389
Karan Gupta
  • 121
  • 4
  • 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 08 '20 at 14:32

1 Answers1

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.

Kadir Şahbaz
  • 76,800
  • 56
  • 247
  • 389