Editing features

After being able to parse all the features, it's necessary to learn how to modify them to satisfy our processing needs. Features can be modified in two ways:

  • Using the data providers of the vector
  • Using the methods of QgsVectorLayer

The difference that exists between these two methods is the ability to interact with some editing features of the QGIS framework.

Updating canvas and symbology

We will now modify the Alaska shapefile in the following subsections. If we modify some geometry of the legend classification, it will be necessary to refresh the canvas and/or layer symbology. The canvas can be refreshed with the following commands:

iface.mapCanvas().clearCache()
iface.mapCanvas().refresh()

The symbology of a modified QgsVectorLayer ...

Get Mastering QGIS - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.