2

Is it possible to automatically (re)classify the data of a layer? (properties-symbology-delete all-classify) Because now I have to do this manually each time my data source changes.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338

2 Answers2

1

You need to write some code to simulate what the GUI is doing. I assume you know at what point your data has changed then you can take a look at Automatic pyqgis categorized renderer classification .

kartoza-geek
  • 1,161
  • 1
  • 7
  • 17
0

Yes it is possible.

  1. Classify everything you want and when it is okay, save the style as shown below. (I suggest you to use the QGis Layer Style File since you will re use it into QGis)

enter image description here

  1. Open your new layer and Load the created style enter image description here
  • 2
    Hi! Thanks for the quick answer, but I don't see how this could automatically update my layer data when the data source has changed... – bcallewaert Mar 04 '19 at 12:42
  • And it still requires a lot of manual proceedings – bcallewaert Mar 04 '19 at 12:44
  • Hey @bcallewaert, it doesn't need so much manual proceedings. In fact, When you are done with your categorization (this means you have selected a field and you've defined colors based on some conditions), your will save your style. Since other layers should have the same structure, by applying your style it will automatically repeat all what you've done in the first layer – Yannick Arthur DOUNGMO Mar 04 '19 at 13:36
  • Is there a possibility I can contact someone from you through mail so I can show what my problem exactly is? Because now it doesn't fix the problem... – bcallewaert Mar 04 '19 at 14:28
  • 4
    Because when I save the Style, it also copies the value present at that time in the cell. So when the data source is changed and I load in the saved style, the previous value is again shown in the table. This, of course, should not be the case. – bcallewaert Mar 04 '19 at 14:31
  • if there are new unique values in the updated data source, this method won't pick them up, but will group them under 'all other values' (if it exists). – Theo F Sep 07 '21 at 13:29