Loading layers

One of the first things you will probably need to do is load some existing GIS data. You can open several different file formats. The method for doing this is the same. It is done by creating a QgsVectorLayer and passing a parameter for the data source, the layer name to be shown in the layers panel widget, and the provider name as shown in the following code:

import requests import json from qgis.core import * from qgis.PyQt.QtGui import * from qgis.PyQt.QtWidgets import * from qgis.PyQt.QtCore import * streets = QgsVectorLayer(r'C:\Users\Paul\Desktop\PythonBook\CHP8\Streets.shp', "Streets","ogr") scf = QgsVectorLayer(r'C:\Users\Paul\Desktop\PythonBook\CHP8\SCF.shp', "SeeClickFix","ogr")

For most vector layers, you will use ...

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.