*We customize the course outline and content to your specific needs and relevant use cases.
Module 1: Introduction to QGIS Programming
- Applications of Python within QGIS
- PyQGIS as the programming interface to QGIS
- Differences between manual, model-based, and scripted workflows
- Typical automation tasks in GIS projects
- Structure of a simple QGIS Python script
- Dividing recurring processes into individual programming steps
- Capabilities and limitations of automation
Module 2: Development Environment and Python Console
- Opening and using the QGIS Python Console
- Running individual commands interactively
- Using command history and automatic completion
- Introduction to the integrated script editor
- Creating, saving, and rerunning script files
- Developing and testing code incrementally
- Reviewing outputs and messages in the console
- Organising scripts and exercise data clearly
Module 3: Reviewing Python Fundamentals for PyQGIS
- Using variables and essential data types
- Processing strings, numbers, and Boolean values
- Working with lists, tuples, and dictionaries
- Creating conditions with if, elif, and else
- Implementing repetition with for and while loops
- Defining and calling functions
- Importing modules and classes
- Applying indentation and basic Python syntax correctly
Module 4: The iface Object as the Interface to QGIS
- Purpose and operation of the iface object
- Accessing the current QGIS project
- Identifying active layers and selected features
- Accessing the map canvas and current extent
- Working with the layer tree and legend
- Refreshing the map and zooming to layers
- Displaying messages and guidance within the QGIS interface
- Supporting user actions through scripts
Module 5: Managing QGIS Projects and Layers
- Accessing the current project through PyQGIS
- Reading layers from a project
- Finding layers by name or ID
- Distinguishing vector and raster layers
- Adding and removing layers
- Controlling layer visibility and order
- Organising layers into groups
- Examining project properties and data sources
Module 6: Loading and Inspecting Vector Layers
- Loading shapefiles and GeoJSON files
- Connecting geodatabase and other vector data sources
- Creating memory-based layers
- Checking whether a layer is valid
- Reading geometry type and coordinate system
- Examining fields and attribute structures
- Determining feature count and spatial extent
- Querying data-source and provider properties
Module 7: Reading Features and Attributes
- Iterating through the features of a vector layer
- Reading feature IDs and attribute values
- Accessing individual fields directly
- Handling null values and different data types
- Filtering features with conditions
- Producing structured attribute output
- Transferring information into lists or dictionaries
- Preparing results for further calculations
Module 8: Creating and Modifying Attributes
- Controlling a layer’s editing mode
- Adding new attribute fields
- Changing field values for individual features
- Updating multiple attribute values automatically
- Performing calculations comparable to the Field Calculator
- Implementing default values and conditional calculations
- Saving or rolling back changes
- Creating safe and traceable editing workflows
Module 9: Selecting and Filtering Features
- Selecting features by ID
- Using attribute-based expressions
- Combining spatial and operational selection conditions
- Reading and modifying existing selections
- Clearing or extending a selection
- Using selected features in subsequent processing steps
- Highlighting results in the map canvas
- Automating selection processes
Module 10: Processing Geometries with PyQGIS
- Reading geometry objects from features
- Distinguishing point, line, and polygon geometry
- Examining coordinates and vertices
- Calculating lengths and areas
- Determining polygon centroids
- Measuring distances between features
- Using bounding boxes and spatial extents
- Writing geometric results to attribute fields
Module 11: Creating Features and Geometries
- Creating simple point geometries with Python
- Building lines from coordinate lists
- Creating polygon geometries
- Assigning geometries and attributes to new features
- Adding features to existing layers
- Creating temporary result layers
- Considering coordinate systems when generating geometry
- Saving and reviewing results
Module 12: Controlling Symbology with Python
- Examining layer renderers and symbols
- Changing symbol colour, size, and outline
- Creating simple symbology programmatically
- Configuring categorised representations
- Preparing graduated symbology
- Controlling displays through attribute values
- Refreshing layer rendering after changes
- Automating symbology workflows for several layers
Module 13: Calling QGIS Tools from Python
- Using existing QGIS functionality programmatically
- Examining available Processing providers and algorithms
- Identifying algorithm IDs and required parameters
- Defining input and output parameters
- Calling tools through Python
- Reviewing results and return values
- Checking error messages and processing information
- Converting manual tool operations into scripts
Module 14: Working with the Processing Module
- Structure and operation of the Processing Framework
- Using tools such as Clip, Buffer, Dissolve, and Export
- Converting data formats
- Processing layers according to attribute or spatial conditions
- Combining multiple tools into a workflow
- Using one tool’s output as the input for a subsequent step
- Introduction to Processing contexts and feedback objects
- Adding results to the project automatically
Module 15: Temporary Layers and Intermediate Results
- Distinguishing temporary and permanent outputs
- Generating processing results in memory
- Using intermediate outputs in subsequent tools
- Examining temporary layers programmatically
- Saving results permanently when required
- Considering the storage requirements and lifetime of temporary data
- Avoiding unnecessary intermediate datasets
- Keeping scripted workflows clear and efficient
Module 16: Workflow Automation
- Analysing a manual GIS workflow
- Defining input data, processing steps, and outputs
- Running multiple Processing tools sequentially
- Generating file names and paths dynamically
- Checking intermediate results
- Controlling alternative workflows with conditions
- Producing progress messages and results
- Making automated processes reproducible
Module 17: Batch Processing with Python
- Automating recurring tasks across several files or layers
- Searching directories and data collections
- Selecting suitable inputs by file name or type
- Using loops for repeated tool calls
- Naming and saving outputs automatically
- Skipping invalid or unsuitable datasets
- Recording progress and processing results
- Testing and optimising batch processes
Module 18: Developing Custom Processing Scripts
- Structure of a Processing script algorithm
- Defining input and output parameters
- Using vector layers, fields, numbers, and file paths as parameters
- Implementing programme logic in the processing method
- Reporting progress and status information
- Returning results to the Processing Framework
- Providing scripts through the Processing Toolbox
- Documenting and reusing custom tools
Module 19: Error Analysis and Debugging
- Distinguishing syntax, runtime, and data errors
- Reading Python and QGIS error messages
- Producing controlled output for variables and intermediate results
- Isolating errors through incremental testing
- Protecting critical code with try and except
- Creating informative custom error messages
- Identifying invalid layers, fields, and file paths
- Testing scripts with different input datasets
Module 20: Best Practices for PyQGIS Scripts
- Using meaningful variable and function names
- Dividing code into clear sections and functions
- Applying comments appropriately and clearly
- Creating docstrings for functions and scripts
- Following common Python code conventions
- Avoiding repeated code
- Validating inputs before processing
- Documenting dependencies and assumptions
- Designing scripts for future maintenance and adaptation
Module 21: Practical Project: An Automated QGIS Workflow
- Selecting and structuring a typical GIS workflow
- Loading and checking input data programmatically
- Reading or modifying features and attributes
- Conducting geometric calculations
- Combining multiple Processing tools
- Managing temporary and permanent results
- Adding error handling and status messages
- Providing the workflow as a custom Processing script
- Testing, documenting, and reviewing the results