Articles in this series
QGIS provides PyQGIS (Python API). It allows developers to built new tools and automates work. QGIS provides Python console for scripting. You can open it from the: Plugins ► Python Console menu. If you like the content, please SUBSCRIBE to my chan...
In the Python console use print() function to write. Print("Hello My Dear Learner!") Then click "Enter" If you like the content, please SUBSCRIBE to my channel for the future content
For long scripts, you can use Script editor. To open it, click on 'Show Editor". If you like the content, please SUBSCRIBE to my channel for the future content
You can download the data that we are using. Then, get the path of the shapefile uri = "D:/Python_QGIS/data/Countries.shp" The format is: vlayer = iface.addVectorLayer(data_source, layer_name, provider_name) iface.addVectorLayer(uri, "countries",...
For loading raster files, GDAL library is used. Firstly, download the data. Then, get the path of the raster file: uri = "D:/Python_QGIS/data/dem_subset.tif" Now add the layer The format is: rlayer = iface.addRasterLayer(data_source, layer_name, pro...
We use fields() on a QgsVectorLayer to retrieve information about the fields of a vector layer. uri = "D:/Python_QGIS/data/Countries.shp" vlayer = QgsVectorLayer(uri, "Countries", "ogr") for field in vlayer.fields(): print(field.name()) If ...