I have a layer and features are selected using Select Features by freehand tool and for that selected features, convex hull was done and for that convex hull i am trying to find buffer and write it in a csv file.It is showing an error "Type Error: "Bool object is not iterable".I dont know where i am wrong.I had attached my code for reference.Help would be appreciated.
layer = iface.activeLayer()
feature = layer.selectedFeatures()
convex_hull = QgsGeometryAnalyzer().convexHull(layer, 'E:/Kcube/test.shp', True, -1, p=None)
for feature in convex_hull:
mbuf = feature.geometry().buffer(50, 2)
iterFeat = layer.getFeatures()
for f in iterFeat:
geom2 = f.geometry()
valTest = QgsGeometry.within(geom2, mbuf)
if valTest:
idx = f.fieldNameIndex('name')
idx1 = f.fieldNameIndex('state')
lsNearCities = []
nearCity = f.attributes()[idx]
state = f.attributes()[idx1]
state_and_cities = str(state) + "," + nearCity
lsNearCities.append(state_and_cities)
print lsNearCities
Aucun commentaire:
Enregistrer un commentaire