Creating a complex vector layer symbol
The true power of QGIS symbology lies in its ability to stack multiple symbols in order to create a single complex symbol. This ability makes it possible to create virtually any type of map symbol you can imagine. In this recipe, we'll merge two symbols to create a single symbol and begin unlocking the potential of complex symbols.
Getting ready
For this recipe, we will need a line shapefile, which you can download and extract from https://github.com/GeospatialPython/Learn/raw/master/paths.zip.
Add this shapefile to a directory named shapes
in your qgis_data
directory.
How to do it...
Using Python Console, we will create a classic railroad line symbol by placing a series of short, rotated line markers along a regular line symbol. To do this, we need to perform the following steps:
First, we load our line shapefile:
lyr = QgsVectorLayer("/qgis_data/shapes/paths.shp", "Route", "ogr")
Next, we get the symbol list and reference the default symbol...