How do I copy some features from one class to another in QGIS modeller?

In ArcGIS it was just "Copy features", but I cannot find it in QGIS.

  • Welcome to GIS:SE @saps! Are you just wanting to copy features from one layer to another (including their attributes)? – Joseph Jun 5 '17 at 9:41
  • Hello. That is the thing I want to do using QGIS processing modeler. – saps Jun 5 '17 at 12:07

You could create a custom script which allows you to copy features (and attributes) from one layer to another. You can run the script either independently from the Processing Toolbox or in your modeler. You can create a script from:

Processing Toolbox > Scripts > Tools > Create new script

Then use something like the following:


original_layer = processing.getObject(original_layer)
copy_to_layer = processing.getObject(Copy_to)

feats = [ feat for feat in original_layer.getFeatures() ]

Copy_to_data = copy_to_layer.dataProvider()
attr = original_layer.dataProvider().fields().toList()

Make sure the script is saved in your /.qgis2/processing/scripts/ directory. Now when you run the script, you can select the original layer and the layer you want to add the copied features to.

  • Thank you. So, when copying features is such a big problem in QGIS modeler then wouldn't it be easier to develop whole process as a Python plugin? – saps Jun 5 '17 at 12:27
  • @saps - Most welcome! I don't think the issue is that it's a problem to implement as a tool, it's probably more of a lack of use-case. Doing it manually really only takes a few clicks from the GUI. Saying that, feel free to submit it as a feature request. It could be a future tool :) – Joseph Jun 5 '17 at 12:39

I also encountered this problem today, but unfortunately, in QGIS 3.2, there is still no such tool. I found that I can use the following method to build a Modeler tool similar to ArcGIS Copy Features tool. But I also think that QGIS can add a standard Copy Features tool.

  1. Add a vector layer
  2. Add a Select by expression and set the expression to $id > -1
  3. Add a Save Selected Features

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.