I am developing a python plugin for QGIS. In QGIS map window, certain features of a vector layer are selected and those features are highlighted. Now I need to delete all the existing features from another vector layer without disturbing current selection in the map window. Is it possible to delete all the features of a vector layer without selecting them?
PyQGIS – How to Delete All Features of a Vector Layer
deletepyqgisqgis-python-consolevector-layer
Best Answer
You could use the following code which is heavily based on the answer from this post: How to delete selected features in QGIS using Python
Edit:
Thanks to @GermánCarrillo, a more efficient method could be to delete all features at once: