In this chapter, we will cover the following recipes:
Creating a vector layer in memory
Adding a point feature to a vector layer
Adding a line feature to a vector layer
Adding a polygon feature to a vector layer
Adding a set of attributes to a vector layer
Adding a field to a vector layer
Joining a shapefile attribute table to a CSV file
Moving vector layer geometry
Changing a vector layer attribute
Deleting vector layer geometry
Deleting a vector layer field
Deleting vector layer attributes
Reprojecting a vector layer
Converting a shapefile to Keyhole Markup Language (KML)
Merging shapefiles
Splitting a shapefile
Generalizing a vector layer
Dissolving vector shapes
Performing a union on vector shapes
Rasterizing a vector layer
Introduction
This chapter details how to edit QGIS vector data using the Python API. The QgsVectorLayer object contains the basics of adding, editing, and deleting features. All other geospatial operations are accessed through the Processing Toolbox or even through custom scripts.