Goal: be able to update ruled based symbology
Data (layer attribute table): a column with the ID of the individual, a column with the date of identification (Year-month), a column with the name of the origin of this individual, and of course the coordinates.
I made a rule-based symbology in order to be able to check/uncheck the features easily by month, and by origin -> this allows me to check for example a month that interests me and select only the individuals from such or such origin. (as you can see in this example:)
Problem: It works very well but the problem is that I have new data every week with new months and new origins and I don't know how to update this symbology without having to start over each time. It is easy to update categorized symbology for example but I couldn't find a solution for the rule-based category.
Does anyone know a way to easily update the rule-based category?
Best Answer
Based on multiple posts like here and here, here's a way to automate rule-based symbology creation, making sure it handes all unique values from two property fields from a given Vector layer (Date and Origin in your case).
This works from the Python console on the active layer:
I tested this code (with other field names) and it works. Some extra python code might be needed if your dates are not already in a YYYY-MM format. Also, for each date, all categories will be listed not only the ones that belond to that date range. This can be improved as well by reworking the script
With this sample data:
here's what you get after running the script: