Font markers open up broad possibilities for icons, but a single-color shape can be hard to see across a varied map background. Recently, QGIS added the ability to place outlines around font marker symbols. In this recipe, we'll use font marker symbol methods to place an outline around the symbol to give it contrast and, therefore, visibility on any type of background.
Download the following zipped shapefile. Extract it and place it in a directory named ms
in your qgis_data
directory:
https://github.com/GeospatialPython/Learn/raw/master/tourism_points.zip
This recipe will load a layer from a shapefile, set up a font marker symbol, put an outline on it, and then add it to the layer. We'll use a simple text character, an @
sign, as our font marker to keep things simple:
First, we need to import the
QtGUI
library, so we can work with color objects:from PyQt4.QtGui import *
Now, we create a path string to our shapefile...