Hello,<br><br>I am triying to write apython plugin to qgis and I got
<meta name="qrichtext" content="1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin: 0px; text-indent: 0px;"><span style="color: rgb(255, 0, 0);">exceptions.AttributeError: vectorType error<span style="color: rgb(51, 0, 0);"> what may be the problem I couldn't find it. The feautre count turns value of 5 and I tried to check if my layer is valid or not. <br>
</span></span></p><p style="margin: 0px; text-indent: 0px;"><br><span style="color: rgb(255, 0, 0);"><span style="color: rgb(51, 0, 0);"></span></span></p><p style="margin: 0px; text-indent: 0px;"><span style="color: rgb(255, 0, 0);"><span style="color: rgb(51, 0, 0);">My code is below:</span></span></p>
<p style="margin: 0px; text-indent: 0px;"><br><span style="color: rgb(255, 0, 0);"><span style="color: rgb(51, 0, 0);"></span></span></p><p style="margin: 0px; text-indent: 0px;"><span style="color: rgb(255, 0, 0);"><span style="color: rgb(51, 0, 0);"><br>
vlayer = QgsVectorLayer("/home/lutfi/Desktop/deneme/borders.shp", "hebe", "ogr")<br> <br><br> print vlayer.featureCount()<br> <br> <br> if not vlayer.isValid():<br> print "Couldn't open the layer"<br>
<br> else:<br># QMessageBox.information(None, "Cancel", "File selection canceled")<br> <br> provider = vlayer.dataProvider()<br> feat = QgsFeature()<br> allAttrs = provider.attributeIndexes()<br>
provider.select(allAttrs)<br> <br> while provider.nextFeature(feat):<br> geom = feat.geometry()<br> print "Feature ID %d: " % <a href="http://feat.id">feat.id</a>()<br> if geom.vectorType() == QGis.Point:<br>
x = geom.asPoint()<br> print "Point: " + str(x)<br><br> elif geom.vectorType() == QGis.Line:<br><br> x = geom.asPolyline()<br> print "Line: %d points" % len(x)<br>
<br> elif geom.vectorType() == QGis.Polygon:<br><br> x = geom.asPolygon()<br> numPts = 0<br> for ring in x:<br> numPts += len(ring)<br> print "Polygon: %d rings with %d points" % (len(x), numPts)<br>
else:<br> print "Unknown"<br> attrs = feat.attributeMap()<br><br> for (k,attr) in attrs.iteritems():<br> print "%d: %s" % (k, attr.toString())<br> <br></span></span></p>