Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 (http://www.qgis.org/api/classQgsRuleBasedRendererV2.html)

>>> 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? –  Andrey 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: stackoverflow.com/questions/231839/… –  Pablo Jan 18 '13 at 13:36
    
Looks like python binding for QgsRuleBasedRendererV2 doesn't contain rootRule() method in version 1.8 github.com/qgis/Quantum-GIS/blob/release-1_8/python/core/… It works ok in 1.9 dev version –  Andrey Jan 23 '13 at 12:13
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.