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 to the properties of the layer itself. Using a rule-based renderer, this recipe demonstrates how to color code a layer based on an attribute.
Getting ready
You will need to download a zipped shapefile from https://geospatialpython.googlecode.com/svn/ms_rails_mstm.zip.
Unzip it and place it in the directory named ms
in your qgis_data
directory.
In this same directory, download and unzip the following shapefile:
https://geospatialpython.googlecode.com/files/Mississippi.zip
Finally, add this shapefile to the directory as well:
How to do it...
We will set up a railroad layer, then we'll set up our rules as Python tuples to color code it based on the frequency of use. Finally, we'll add some other layers to the map for reference. To do this, we need to perform the following steps:
- First...