GeoPython 2021

Python in QGIS
2021-04-22, 13:30–14:00, Track 1

Python can be used in many ways in QGIS. The presentation shortly introduces how and where Python can be used from the QGIS Python console to the standalone QGIS Python applications.


QGIS gives several opportunities to the users/developers to extend its capabilities using Python. During the presentation we walk through most of them. Besides pure Python a basic knowledge of QGIS PyAPI should be picked up. Fortunately there are many free tutorials, handbooks to help with the beginning steps. Tips are presented where to start.
We start our journey with the QGIS Python console and script editor. It is an easy to use tool to execute direct Python commands or to write short scripts for yourself and your colleagues. ScriptRunner plugin gives a more comfortable environment for your simple scripts. A GUI helps you to organize scripts and metadata, too.
You can write your own functions for Field Calculator. It is the next level of Python intrusion. This helps to make field calculator more powerful to solve your specific tasks.
Python actions are the first in our series which extend the user interface for non programmers, too. There are different actions types, but Python actions are the most environment independent ones. They will work on all supported platforms.
While the previous Python intrusions are useful for creative users with some programming background, with the next three you can create easy to use modules, programs for any QGIS user. The easiest from the point of view of the programmer is the so called Processing script, which can be used from the processing framework. You do not need to deal with GUI a lot, there is a simple environment to define GUI elements for input parameters of the script, which are managed by the Processing framework. If you would like to create an interactive tool in QGIS with its own GUI elements, you should create a plugin or a standalone application. For this you need some Qt practice, too.
Short simple examples are presented for each above mentioned opportinuities.