Introduction to PyQGIS

Site: OpenCourseWare for GIS
Course: Programming Basics for QGIS Users
Book: Introduction to PyQGIS
Printed by: Guest user
Date: Sunday, 11 January 2026, 3:09 AM

1. Introduction

Python is one of the most powerful ways to extend, automate, and deepen your work in QGIS. In this tutorial, you’ll take your first steps with PyQGIS in a notebook environment. You’ll learn how to access layers, inspect data, run spatial operations, and visualize results.

With the Notebook plugin, you can now run Jupyter Notebooks directly inside QGIS, combining the clarity of interactive Python code with the full capabilities of the QGIS API. This creates a smooth, modern workflow for learning, experimenting, and building reproducible GIS analyses.

This tutorial is based on previous materials developed by Vincent Post and Hans van der Kwast as part of a course for the Australian Water School.

2. Install the Notebook plugin

With the Notebook plugin we can use Jupyter Notebooks within QGIS. Let's install the plugin.

  1. Start QGIS Desktop.
  2. Go to the Plugins Manager and install the Notebook plugin.
  3. After installing, go in the main menu to Notebook | Check for Updates.... There might be a newer version available that is not yet accepted in the official QGIS repository.
  4. Click Check for Updates.
  5. If there's an update, like in the screenshot above, click Download and Install and follow the instructions and restart QGIS.
  6. In the Toolbar, click to change the settings if necessary. For example, you can change the Color scheme to Light if you're not using QGIS in dark mode.
  7. Click Save Settings and close the Notebook Settings panel.

For some settings you need to restart QGIS to take effect. This is the case for switching to another colour scheme.

In the next chapter, we'll load an existing Jupyter Notebook that we'll work with.

3. Load the Jupyter Notebook

Now you've installed Jupyter Lab in your QGIS OSGeo4W environment, you want to use it with Jupyter Notebooks.

  1. Go to Python for QGIS (GitHub)
  2. Click on Code and then on Download ZIP. Extract the ZIP-file to a folder where you want to work for this tutorial, e.g. Z:\Python_for_QGIS

3. Start QGIS Desktop.

4. In the toolbar, click on to open the Notebook panel.

Now you'll see the Jupyter Notebook panel on the right side of the screen. The panel is docked by default. You can resize it or undock the panel if needed.

5. In the Jupyter Notebook panel, click Open.

6. Browse to the Introduction_to_PyQGIS.ipynb file and click Open.

Now the Jupyter Notebook for this tutorial is loaded and you can follow its instructions for the rest of the tutorial.

Read the written instructions in the cells and for the cells, click the button to execute the code.

4. Conclusion

You’ve now taken your first steps into working with PyQGIS. This foundation will serve you well as you move into more advanced topics. In the next tutorials, you’ll build on what you’ve learned by writing your own scripts in the QGIS Python Console, automating spatial workflows, and creating reproducible analyses that you can share with others.

In this tutorial you have used the Notebook plugin. This video by the developer Qiusheng Wu shows more about the plugin: