
QGIS Python Programming Cookbook, Second Edition
By :

A newer feature of QGIS is filled marker symbols. Filled marker symbols are powerful features that allow you to use other symbols such as point markers, lines, and shape bursts, as a fill pattern for a polygon. Filled marker symbols allow for an endless set of options for rendering a polygon. In this recipe, we'll do a very simple filled marker symbol that paints a polygon with stars.
Download the zipped shapefile and extract it to your qgis_data
directory into a folder named ms
from https://github.com/GeospatialPython/Learn/raw/master/Mississippi.zip.
A filled marker symbol requires us to first create the representative star point marker symbol. Then, we'll add that symbol to the filled marker symbol and change it with the layer's default symbol. Finally, we'll repaint the layer to update the symbology:
First, create the layer with our polygon shapefile:
lyr = QgsVectorLayer("/qgis_data/ms/mississippi.shp", ...