I am developing a plugin that checks for multipart geometry in a layer in qgis 2.6. I am geeting an error list object has no attribute getFeatures. My code snippet is attached below.
def run(self):
"""Run method that performs all the real work"""
# show the dialog
self.dlg.show()
# Clear the QcomboBox before loading layers
self.dlg.multipartcombo.clear()
#self.dlg.multipartcombo.clear()
layer = self.iface.mapCanvas().layers()
for layer in layer:
if layer.type() == QgsMapLayer.VectorLayer:
self.dlg.multipartcombo.addItem( layer.name(), layer )
# Run the dialog event loop
result = self.dlg.exec_()
# See if OK was pressed
# Find all multipart features in the active layer
if result:
layer = self.dlg.multipartcombo.itemData(self.dlg.multipartcombo.currentIndex())
iter = layer.getFeatures()
geoms = []
for feature in iter:
geom = feature.geometry()
if geom.isMultipart():
layer.select(feature.id())
geoms.append(geom)
if result == 1:
index = self.dlg.featurecombo.currentIndex()
layer = self.dlg.featurecombo.itemData(index)
if layer > 0:
QMessageBox.information(self.iface.mainWindow(), 'There are %i multipart features in this layer' % len(geoms))
else:
QMessageBox.information(self.iface.mainWindow(),"Warning!",'Load a layer!')