From the course: Learning QGIS

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create a Python script

Create a Python script - QGIS Tutorial

From the course: Learning QGIS

Start my 1-month free trial

Create a Python script

Scripting with QGIS is a great way to perform repeatable tasks and steps without having to manually perform them over and over again. Using Python, we can import and export, perform an analysis, even create reports. We will use Python to export a point layer into a text file, or CSV, that we can open in applications such as Excel. Let's try that now. First, I'm going to start a new project and I'm going to bring in the intersections shape file. They're basically points of all the intersections in my city. Once I have that, I'm going to write a little bit of Python inside the Python console. The first thing I'm going to do is bring in the layer list. So I'm going to have the layer list equals current project, the instance, and I'm going to grab the maps layers by name. So it'll grab all the layers that are called intersections. In this case, there's only one, so I'll do that. Now I have the layer list. Now of that, I could…

Contents