I have a standalone script that call general.runalg(qgis:linestopolygons...) all ok, but only convert the first feature, and I do previous "selectAll", why ?
Full code:
#!/usr/bin/env python
import qgis
from qgis.core import *
import sys, os
app = QgsApplication([],True, None)
app.setPrefixPath("/usr", True)
app.initQgis()
sys.path.append('/usr/share/qgis/python/plugins')
from processing.core.Processing import Processing
Processing.initialize()
from processing.tools import *
Processing.initialize()
inFile="temp.shp"
poly_output_file=os.path.splitext(os.path.basename(inFile))[0]+"_poly.shp"
vlayer = QgsVectorLayer(inFile, "temp", "ogr")
print "Elements loaded:"+str(vlayer.featureCount()) # shows number elements loaded
vlayer.selectAll()
general.runalg("qgis:linestopolygons",vlayer,poly_output_file)
# note
# you can also call (but same result), only 1 feature into output:
# general.runalg("qgis:linestopolygons",inFile,poly_output_file)
# Exit applications
#app.exitQgis() # give segmentation fault
app.exit()
The temp_poly.shp file is created, but only have one polygon (the first feature).
If I try to convert the same file in, but using QGIS desktop GUI all features are convert to polygons, so is not a problem from source file.