Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can't get access to the rules of rule-based renderer, python says there's no attribute "rootRule", though documentation says it should be (

>>> layer = qgis.utils.iface.activeLayer()
>>> renderer = layer.rendererV2()
>>> type(renderer)
<class 'qgis.core.QgsRuleBasedRendererV2'>
>>> renderer.rootRule()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: 'QgsRuleBasedRendererV2' object has no attribute 'rootRule'

Is it because there's no python binding for rootRule() method? Is there other way to access the rules of the renderer?

I am using QGIS 1.8.0

share|improve this question
Be careful with type() because python is polymorphic. layer.rendererV2() returns a QgsFeatureRendererV2 and not a QgsRuleBasedRendererV2. – Pablo Jan 18 '13 at 12:56
Still due to polymorphism renderer has to contain attributes specific to QgsRuleBasedRendererV2, right? – Andrei Jan 18 '13 at 13:30
No, it can be disabled in python or set to private in C++, I think that's the case. look here:… – Pablo Jan 18 '13 at 13:36
Looks like python binding for QgsRuleBasedRendererV2 doesn't contain rootRule() method in version 1.8… It works ok in 1.9 dev version – Andrei Jan 23 '13 at 12:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.