Symbolizing a vector layer
The appearance of layers on a QGIS map is controlled by its symbology. A layer's symbology includes the renderer and one or more symbols. The renderer provides rules dictating the appearance of symbols. The symbols describe properties, including color, shape, size, and line width. In this recipe, we'll load a vector layer, change its symbology, and refresh the map.
Getting ready
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.Â
How to do it...
We will load a layer, add it to the map layer registry, change the layer's color, and then refresh the map. To do this, perform the following steps:
First, using Python Console, we must import the
QtGui
library in order to access theQColor
object, which is used to describe colors in the PyQGIS API:from PyQt4.QtGui import *
Next, we create our vector layer, as follows:
lyr = QgsVectorLayer...