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 ways 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 command:
iface.mapCanvas().refresh()
The symbology of a modified QgsVectorLayer
instance saved in the myVector
variable can be updated with the following code:
iface.legendInterface().refreshLayerSymbology(myVector)
Editing through QgsVectorDataProvider
Each QgsMapLayer
, as a QgsVectorLayer
instance, has its own data provider that can be obtained with the dataProvider...