Python Training

Course Outlines

Our primary Python trainer is Matt Walker (@_walkermatt). 

Matt has extensive experience working with GIS and programming languages (Python, JavaScript, Java) spanning over 15 years.

Matt has a passion for Open Source and regularly provides workshops at various Open Source events. He has been working with Python since 2011 having been the author of the Open Source GML Loader and provided commits to other projects such as MapProxy.

Matt is a charter member of the OSGeo Foundation.

 

Astun offers two one day Python courses; Python Essentials is an introduction to the the essentials of the language, prior programming knowledge is a pre-requisite. The second course, Python for QGIS takes knowledge gained in Python Essentials and applies it to use within QGIS.

Python Essentials (1 day)

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 course.

The course runs from 9.30am to 5pm.

The course covers the following topics:

1.Setup
  • Installation, Executing Scripts, Using the interpreter
2. Introduction
  • Imports, Functions, Indentation, Variables
3. Strings
  • Strings, if condition,
  • Exercise  - basic/stringl.py
4. Lists
  • Lists, Looping
5. Sorting
  • Sorted function, Tuples
  • Exercise - basic/stringl.py
6. Dicts and Files
  • Dicts, Reading and writing files, Extra: Using with context manager,  Unicode Errors Simply Explained
  • Exercise - basic/wordcount.py
7. Regular Expressions
  • Exercise - babynames/babynames.py
8. The standard library
  • File System, Errors and Exceptions, HTTP (optional)
  • Exercise - copyspecial/copyspecial.py
  • Exercise - logpuzzle/logpuzzle.py (optional)
9. Further Topics
  • Introduction to classes
  • Installing packages via pip (python -m pip)
  • Postgres using psycopg, Python psycopg2 & PostGIS

Book your place now

Python for QGIS (1 day) 

This course assumes some previous knowledge of Python and a basic familiarity with QGIS. It covers using Python to interact with and extend QGIS.

The course runs from 9.30am to 5pm.

The course covers the following topics:

1. Brief introduction to QGIS
  • The User Interface
2. An introduction to PyQGIS
  • What's possible
3. Python Expressions
  • Exercise - Using Custom Python Expression Functions
4. Using the QGIS Python console
  • Exercise - Getting started with Python Programming
  • Extras
    • String formatting (4 decimal places for coordinates)
    • Write column header
    • Output all columns (see info about attributes and accessing attributes)
    • Create a function
    • Use with other layers
    • Handle there being no selected layer (hint: display a QgsMessageBar, as shown in Communicating with the user)
5. Exploring the PyQGIS API
  • Loading Projects, Layers
  • Using Vector Layers
  • Filter vector features
  • Vector layer summary
  • Geometry Handling
  • Map Rendering and Printing
  • Logging
6. Plugins
  • Use function written in [Getting Started With Python Programming]
  • Alert the user when the process is complete (hint: QgsMessageBar from Communicating with the user)
  • Change the iconExtras
7. Writing a Processing plugin
8. Further topics
  • Database access via QGIS

Book your place now