Introduction to PyQGIS

1. Introduction

In this tutorial you'll be introduced to PyQGIS, the Python library of QGIS.

We'll work on an example script where we create a Stage Volume Curve using PyQGIS within and outside of QGIS.

A Stage Volume Curve or Stage Storage Curve can be used to read which volume of a lake or a pit belongs to a certain water level. It's much easier to measure the water level than the volume, so once the curve is created the volume can be determined in an easy way.

In this tutorial we'll create a Stage Volume Curve for an open pit Lignite mine, but the method is the same for lakes.

After this tutorial you'll be able to

  • calculate the volume below a specific elevation in a DTM
  • use QGIS Processing Tools with PyQGIS in QGIS
  • use PyQGIS in Python without the QGIS user interface
  • create a Stage Volume Curve using PyQGIS and Pandas
The data included in this tutorial comes from the Shuttle Radar Topography Mission: SRTM 1-Arc Second. If you want to apply the tutorial to other areas you can download the data from USGS Earth Explorer.