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.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
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:
##Copy_features=name ##original_layer=vector ##Copy_to=vector 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() Copy_to_data.addAttributes(attr) copy_to_layer.updateFields() Copy_to_data.addFeatures(feats)
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.
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.