I am trying to combine all features of a Polygon layer in QGIS in a python plugin, and am running into this error when I try to run the combine method:
"AttributeError: 'NoneType' object has no attribute 'combine' Python version: 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]
QGIS version: 2.10.1-Pisa Pisa, d20c5b7"
I've looked at this question before but am not sure what I am doing incorrectly:
from qgis.core import * from PyQt4.QtCore import QSettings, QTranslator, qVersion, QCoreApplication from PyQt4.QtGui import QAction, QIcon, QFileDialog # Initialize Qt resources from file resources.py import resources, processing # Import the code for the dialog from save_attributes_dialog import SaveAttributesDialog import os.path
Here is my code for the run method:
def run(self): layers = self.iface.legendInterface().layers() layer_list =  for layer in layers: layer_list.append(layer.name()) self.dlg.comboBox.addItems(layer_list) # show the dialog self.dlg.show() # Run the dialog event loop result = self.dlg.exec_() # See if OK was pressed if result: selectedLayerIndex = self.dlg.comboBox.currentIndex() selectedLayer = layers[selectedLayerIndex] features = selectedLayer.getFeatures() geoms = QgsGeometry() for feature in features: geoms = geoms.combine(feature.geometry())
I ran the loop just printing out the areas of each feature before which worked fine, so I'm guessing it is able to access the features without a problem, but am not sure what to do about the NoneType issue.