The Polygonize tool outputs a vector polygon file from two or more intersecting line features contained in one or more input vector line files. Each space enclosed by the intersecting line set is converted to polygon added to the output layer. This tool should not be confused with the Lines To Polygons tool, which can be used to convert a vector file of polylines into a set of polygons, simply by closing each line feature. It does not deal with line intersection in the same way that the Polygonize tool does.
The following is an example of a Python script that uses this tool:
wd = pluginHost.getWorkingDirectory()
# You may have multiple input files but they must
# be separated by semicolons in the string.
inputFiles = wd + "input1.shp" + ";" + wd + "input2.shp"
outputFile = wd + "output.shp"
args = [inputFiles, outputFile]
pluginHost.runPlugin("Polygonize", args, False)
This is a Groovy script also using this tool:
def wd = pluginHost.getWorkingDirectory()
// You may have multiple input files but they must
// be separated by semicolons in the string.
def inputFiles = wd + "input1.shp" + ";" + wd + "input2.shp"
def outputFile = wd + "output.shp"
String[] args = [inputFiles, outputFile]
pluginHost.runPlugin("Polygonize", args, false)