I'm trying to write an action that moves a pointfeature from one layer to another. It works fine until i try to save the layer with the new feature on. He says he can't save a MULTIPOINT to a point-layer.
Any idea why it suddenly becomes a Multipoint?
I based this code on the following question: How to create a QGIS action which copies features between layers?
Here is my code:
def getVectorLayerByName( layerName ): layerMap = QgsMapLayerRegistry.instance().mapLayers() for name, layer in layerMap.iteritems(): if layer.type() == QgsMapLayer.VectorLayer and layer.name() == layerName: if layer.isValid(): return layer else: return None iface = qgis.utils.iface sourcelayer = getVectorLayerByName('plane') iface.setActiveLayer(sourcelayer) sourcelayer.startEditing() iface.actionCutFeatures().trigger() sourcelayer.commitChanges() targetlayer = getVectorLayerByName('dots') iface.setActiveLayer(targetlayer) targetlayer.startEditing() iface.actionPasteFeatures().trigger() targetlayer.commitChanges()