Rendering map layers based on rules

Rendering rules provide a powerful way to control how and when a layer is displayed relative to other layers or properties of the layer itself. This recipe demonstrates how to use a rule-based renderer to color code a layer based on an attribute.

Getting ready

You will need to download a zipped shapefile from the following URL:

https://github.com/GeospatialPython/Learn/raw/master/ms_rails_mstm.zip

Unzip it and place it in directory named ms in your qgis_data directory.

In that same directory, download and unzip the following shapefile:

https://github.com/GeospatialPython/Learn/raw/master/Mississippi.zip

Finally, add this shapefile to the directory as well:

https://github.com/GeospatialPython/Learn/raw/master/jackson.zip ...

Get QGIS Python Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.