I'm trying to make a script for converting polygons to lines. But I'm having some issues while generating temporary layers.
In this script, I iterate through all the features of the input layer to run the function "qgis:simplifygeometrics" on each of them, after that I merge all layers back together. (This is a simplified case of my script)
However, I'm getting the following error when I run my script : TypeError: 'QgsVectorLayer' object has no attribute '_getitem_' and can't find out why.
Any help is welcome, I'm new to Python and SEXTANTE!
Code:
#Creation of the virtual output layer
vOutputLayer = SextanteVectorWriter(vOutputLayer, None, fields, QGis.WKBPolygon, layer.crs())
feats = sextante.getfeatures(layer)
for inFeat in feats:
#Creation of the virtual input layer
vInputLayer = QgsVectorLayer("Polygon", "tmp_input_vector", "memory")
vInputLayer.addFeature(inFeat)
vInputLayer.updateExtents()
#Creation of the virtual layer for the simplified geometries
simplifiedLayer = QgsVectorLayer("Polygon", "tmp_simplified_vector", "memory")
#Simplify Geometries function
sextante.runalg("qgis:simplifygeometries", vInputLayer, 1.0, simplifiedLayer)
simplifiedLayer.updateExtents()
#Merging of layers
sextante.runalg("qgis:mergevectorlayers", simplifiedLayer, vOutputLayer, vOutputLayer)
Complete error :
Traceback (most recent call last):
File "C:\OSGeo4W\apps\qgis-dev\python\plugins\sextante\core\GeoAlgorithm.py", line 145, in execute
self.checkOutputFileExtensions()
File "C:\OSGeo4W\apps\qgis-dev\python\plugins\sextante\core\GeoAlgorithm.py", line 238, in checkOutputFileExtensions
if not os.path.isabs(out.value):
File "C:\OSGeo4W\apps\Python27\lib\ntpath.py", line 57, in isabs
s = splitdrive(s)[1]
File "C:\OSGeo4W\apps\Python27\lib\ntpath.py", line 125, in splitdrive
if p[1:2] == ':':
TypeError: 'QgsVectorLayer' object has no attribute '__getitem__'