Adding features to an existing layer

To add data to a layer, you first need to load the layer. Start by loading a subset of some SeeClickFix data for Albuquerque as shown in the following code:

scf = iface.addVectorLayer(r'C:\Users\Paul\Desktop\PythonBook\CHP8\SCF.shp', "SeeClickFix","ogr") 

The previous code loads and displays the layer on the map. It is the same code from the first section of this chapter.

You do not need to display the layer on the map to work with it. You can load the layer using scf = QgsVectorLayer("C:\Users\Paul\Desktop\PythonBook\CHP8\SCF.shp", "SeeClickFix","ogr").

Now that you have the layer loaded you can use capabilitiesString() to see what operations the provider allows on the data. The following code shows the ...

Get Mastering Geospatial Analysis with Python 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.