In this chapter, we will cover the following recipes:
Accessing the map canvas
Changing the map units
Iterating over layers
Symbolizing a vector layer
Rendering a single band raster using a color ramp algorithm
Creating a complex vector layer symbol
Using icons as vector layer symbols
Creating a graduated vector layer symbol
Creating a categorized vector layer symbol
Creating a map bookmark
Navigating to a map bookmark
Setting scale-based visibility for a layer
Using SVG for layer symbols
Using pie charts for symbols
Using the OpenStreetMap service
Using the Bing aerial image service
Adding real-time weather data from OpenWeatherMap
Labeling a feature
Changing map layer transparency
Adding standard map tools to the canvas
Using a map tool to draw points on the canvas
Using a map tool to draw polygons or lines on the canvas
Building a custom selection tool
Creating a mouse coordinate tracking tool
Introduction
In this chapter, we'll programmatically create dynamic maps using Python to control every aspect of the QGIS map canvas. We'll learn how to use custom symbology, labels, map bookmarks, and even real-time data. We'll also go beyond the canvas to create custom map tools. You will see that every aspect of QGIS is up for grabs with Python, to write your own application. Sometimes, the PyQGIS API may not directly support your application goal, but there is nearly always a way to accomplish what you set out to do with QGIS.