-
Book Overview & Buying
-
Table Of Contents
QGIS Python Programming Cookbook
By :
The QgsComposition object allows you to place arbitrary text anywhere in the composition. In this recipe, we'll demonstrate how to add a label to a map composition.
You will need to download the following zipped shapefile and extract it to your qgis_data directory, to a subdirectory named hancock:
https://geospatialpython.googlecode.com/svn/hancock.zip
In addition to the shapefile, you will also need the MapComposer class. This class encapsulates the boilerplate composer code in a reusable way to make adding other elements easier. You can download it from https://geospatialpython.googlecode.com/svn/MapComposer.py.
This file must be accessible from the QGIS Python console by ensuring that it is in the Python path directory. Place the file in the .qgis2/python directory within your home directory.
To add a label to a composition, we'll first build the map composition, create a label, and then save the composition as an...
Change the font size
Change margin width
Change background colour