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