November 2018
Beginner to intermediate
272 pages
5h 36m
English
One of the first things we will want to do is to load some data. For example, to load a vector layer, we use the addVectorLayer() function of iface. In the following example, I am adding the airport.shp. This is shown in a single line of code as follows:
v_layer = iface.addVectorLayer('D:/QGIS_3_4/qgis_sample_data/shapefiles/airports.shp','airports','ogr')
When we execute this command, airports.shp will be loaded using the ogr driver and added to the map under the layer name of airports. Additionally, this function returns the created layer object. Using this layer object that we stored in v_layer, we can access vector layer functions such as name(). This returns the layer name and is displayed ...
Read now
Unlock full access