January 2019
Beginner
164 pages
3h 15m
English
To load a vector layer, we use the addVectorLayer() function of iface. The iface class is used to access the graphical part of the QGIS interface. In the following example, I am adding airport.shp to the map. This is shown in one line of code, as follows:
Airport_layer = iface.addVectorLayer('D:/QGIS_quickstart/qgis_sample_data/shapefiles/airports.shp','airports','ogr')
Press the Enter key and the airports layer is now loaded (change the path to your Shapefile):

Add another layer:
Alaska_layer = iface.addVectorLayer('D:/QGIS_quickstart/qgis_sample_data/shapefiles/alaska.shp','alaska','ogr') ...Read now
Unlock full access