As it could be useful to some people, here's a little script to copy / paste selected features from a layer to another.
For a lot of layers, I use at first the MultipleLayerSelection (here's the 3.0 beta : https://github.com/felferrari/MultipleLayerSelection) that permits to select features from all layers with a rectangle. Adapts and run this script : --- def selectedFeaturesCopy(sourceLayerName, destLayerName): sourceLYR = QgsProject.instance().mapLayersByName(sourceLayerName)[0] destLYR = QgsProject.instance().mapLayersByName(destLayerName)[0] destLYR.startEditing() # uncomment (remove the #) the following line to delete features in the destination layer first #destLYR.deleteSelectedFeatures() iface.copySelectionToClipboard(sourceLYR) iface.pasteFromClipboard(destLYR) # uncomment the following line to commit your changes automatically. Personally I prefer to verify first ;) #destLYR.commitChanges() # Create and adapt as much as lines as you have layers to copy selectedFeaturesCopy('source layer 1', 'destination layer 1') selectedFeaturesCopy('source layer 2', 'destination layer 2') ---
_______________________________________________ Qgis-user mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
