Implementing renderers in Python
If you need to choose symbols based on more complicated criteria than the built-in renderers will provide, you can write your own custom QgsFeatureRendererV2
subclass using Python. For example, the following Python code implements a simple renderer that alternates between odd and even symbols as point features are displayed:
class OddEvenRenderer(QgsFeatureRendererV2): def __init__(self): QgsFeatureRendererV2.__init__(self, "OddEvenRenderer") self.evenSymbol = QgsMarkerSymbolV2.createSimple({}) self.evenSymbol.setColor(QColor("light gray")) self.oddSymbol = QgsMarkerSymbolV2.createSimple({}) self.oddSymbol.setColor(QColor("black")) self.n = 0 def clone(self): return OddEvenRenderer() def symbolForFeature(self, feature): self.n = self.n + 1 if self.n % 2 == 0: return self.evenSymbol else: return self.oddSymbol def startRender(self, context...