Python Essentials training
An introduction to thinking in a Pythonic way covering the fundamentals of the language and putting you in good stead for the Python for QGIS training course.
1 day
Setup
Installation, executing scripts and using the interpreter
Intro
Imports, functions, indentation and variables
Strings
Strings, if condition
Exercise – basic/stringl.py
Lists
Lists and looping
Sorting
Sorted function, Tuples
Exercise – basic/stringl.py
Dicts and files
Dicts, Reading and writing files, Extra: Using with context manager, Unicode Errors Simply Explained
Exercise – basic/wordcount.py
Regular Expressions
Exercise – babynames/babynames.py
The standard library
File System, Errors and Exceptions, HTTP (optional)
Exercise – copyspecial/copyspecial.py
Exercise – logpuzzle/logpuzzle.py (optional)
Further Topics
Introduction to classes
Installing packages via pip (python -m pip)
Postgres using psycopg, Python psycopg2 & PostGIS
Interested in Python training?
Python for QGIS training
A one day course covering using Python to interact with and extend QGIS. This course assumes some prior knowledge of Python (such as our Python Essentials course) and a basic familiarity with QGIS to really maximise your implementation.
1 day
4 CPD pointsIntroduction to Python
A quick refresher on what Python is and a look at some of its key features. This course assumes that you have
some skills in programming (preferably in python) and are looking to understand how to use Python with QGIS.
Introduction to PyQGIS
QGIS has a powerful programming interface that allows you to extend the core functionality of the software as
well as write scripts to automate your tasks. QGIS supports the popular Python scripting language. Even if you
are a beginner, learning a little bit of Python and QGIS programming interface will allow you to be much more
productive in your work.
Using the QGIS Python Console
QGIS contains a full installation of Python that is available in the console, this section gives an introduction to its use in interacting with data layers and features to allow you to enhance your data
exploration and mapping.
Python Expressions
It is possible to add simple functionality to QGIS using the command console to write custom functions that
modify attributes of your features. This section will show you how to write and deploy a custom function to
calculate the UTM zone number of a point on the map.
PyQGIS API
PyQGIS is the Python API provided by QGIS to allow programmers direct access to all of the QGIS interface.
Here we will look at the possibilities provided by the API to control QGIS, access and modify data.
Creating a plugin
In the final session of the course we work through two fully working scripts, a plugin to provide a new tool for QGIS users and a new processing script to add a custom process to the processing tool box.