In this video, I will show you how to add vector and raster layer data using Python console in QGIS | Geology GIS.
Hello friends, welcome to my Channel,
Today, I am going to show you how to add Vector data and raster data by using the python console before going to do that in my previous video, I have shown how to use this python in qgis. If you have not seen that video, please watch that video by clicking the link which is given in the description. Generally, you might be adding any vector layer by going to browse the vector data and by selecting the shapefile. Generally, you might be using this conventional method for
adding any Vector data or any raster data. We are going to see how to add this vector and raster layer by using the pyqgis now you can notice this python console is open. I will show you how to add and display a vector layer in order to save our time. I have written the following steps in the script and saved it as a python file. So let me open it first. Here I will add the vector data in three different ways in the first method we are going to use the easiest way to open and display a vector layer. This is the add vector layer. Here we have Simply used this command iface.addVectorLayer. And when we run this script, we can notice that the vector layer is added. In this second method first, We are going to use the qgis vector layer by mentioning the root of the file and name of the shapefile and it's format. Here ogr, Is the library which reads and write the vector data formats. And here, We are going to register the layer and then we are going to add map layer. So when you run the script, we can notice that the shape file is now added. In the third method. we are going to import some modules. And the same steps are added as in the form of variables. Like I'm going to call it as a layer as we done before qgis vector layer. What is the path? What is the name of the shapefile (lake)? And what is that format? Then I'm going to use the instant method. So I'm going to call it as a variable, right? Qgis map layer registry instance. Then again, I'm going to call the registered variable to add a map layer. And If I run the script, we can notice that, The vector layer or the shapefile is now added. In order to view the attribute table. We my right click and we can assess it. Whereas, here I have used I face.showattributetable. command to view the attribute table. In order to add the raster data, we are going to use the easiest way which is the add raster layer and when you run the script, we notice that the raster data is added. So this is how we can add the vector and raster layer by
using the command in the python console. I hope You may like this video and leave your comments and subscribe to my channel for more videos.
qgis python - QGIS Python Console | Introduction to PYQGIS
• "Exploring the QGIS Python Console: A...
Welcome to Geology GIS
http://bit.ly/3b75Zim
Please use this link to subscribe to this channel and tap the bell icon for more videos
Also have look to my previous videos
have a look on my web page
https://ilayarajak.github.io/lecturen...
How to create a shapefile in QGIS:
• qgis tutorial | how to create shapefi...
I have used this link to record this video
https://obsproject.com/download