-
Book Overview & Buying
-
Table Of Contents
QGIS Python Programming Cookbook
By :
A categorized vector layer symbol allows you to create distinct categories with colors and labels for unique features. This approach is typically used for datasets with a limited number of unique types of features. In this recipe, we'll categorize a vector layer into three different categories.
For this recipe, we'll use a land use shapefile, which you can download from https://geospatialpython.googlecode.com/svn/landuse_shp.zip.
Extract it to a directory named hancock in your qgis_data directory.
We will load the vector layer, create three categories of land use, and render them as categorized symbols. To do this, we need to perform the following steps:
First, we need to import the QColor object for our category colors:
from PyQt4.QtGui import QColor
Then, we load the vector layer:
lyr = QgsVectorLayer("Users/joellawhead/qgis_data/hancock/landuse.shp", "Land Use", "ogr")
Next, we'll create our three land use categories using...
Change the font size
Change margin width
Change background colour