Geographic Information Systems Asked on August 2, 2021
I have a QgsCategorizedSymbolRenderer
and I’m trying to configure it so that symbol_a
:
QgsRendererCategory
symbols (i.e. it should be rendered last).In QGIS, I can do this by going to Symbology > Advanced > Symbol Levels
, checking Enable symbol levels
and configuring the Layer 0
for Label A
to 1
, leaving the others at 0
.
Using PyQGIS, I can enable symbol levels, but can’t find a way to change the specific symbol levels (i.e. the order they are rendered). Re-ordering the categories achieves this, but I’d prefer Label A
to appear first in the layers window. Is this possible?
My existing code looks something like this:
categories = [
QgsRendererCategory('value_a', symbol_a, 'Label A'),
QgsRendererCategory('value_b', symbol_b, 'Label B'),
QgsRendererCategory('value_c', symbol_c, 'Label C'),
]
renderer = QgsCategorizedSymbolRenderer('field_name', categories)
renderer.setUsingSymbolLevels(True)
This post give a good answer with a clause applied on the renderer :
myRenderer.setOrderBy(QgsFeatureRequest.OrderBy([QgsFeatureRequest.OrderByClause('Value', False)]))
myRenderer.setOrderByEnabled(True)
Answered by GeoGyro on August 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP