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
-
2Welcome 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– Ian Turton2020年09月08日 14:32:34 +00:00Commented Sep 8, 2020 at 14:32
1 Answer 1
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
lang-py