I have created this code to categorize my layer symbology based on the attribute "plant_allo"plant_allo
. However I still have to press the classify button which I also want to automate in pyqgisPyQGIS. Can anyone help me with this last step?
Here is my code:
year = 2030
allocated_regions = QgsVectorLayer(output_folder + "regions_w_plant_alloc_" + str(year) + ".shp", "allocated_regions_" + str(year), "ogr")
QgsProject.instance().addMapLayer(allocated_regions)
# Field name
expression = 'plant_allo'
# Set the categorized renderer
renderer = QgsCategorizedSymbolRenderer(expression)
allocated_regions.setRenderer(renderer)
allocated_regions.triggerRepaint()