4

I'm using QGIS 3.16. I've some data where secret statistic values are encoded as -9999 in multiple columns. When I go in the layer tab "Symbology", I choose to use "Graduated", then select my column name. Then, I press "Classify". It includes my -9999 values but I want to exclude them. I've already had solutions to do it e.g

  • using PyQGIS using methods inherited from https://qgis.org/api/classQgsClassificationMethod.html to classify and push the classification in Rule-based symbology
  • filter provider source on my column to exclude -9999, classify, transform Symbology as Rule-based and then remove the filter and add the -9999 value in a new rule

I would prefer a GUI based approach so, solution 1 is not what I want.

The solution #2 needs a lot of intermediate steps each time and need to be repeated too frequently e.g for each column or each classification change.

Do you have any other approach to solve this issue e.g excluding one or more values before using "Graduated" classification?

Ideally, I should be able to exclude it using the GUI but it's not possible in the current QGIS (to my knowledge).

1 Answer 1

7

You have just to create a QGIS expression for your graduated symbology nullif("your_field_of_values", -9999) (QGIS Documentation), NULL values are excluded.

To exclude many values, consider a filter like CASE WHEN ... END statement (QGIS Documentation).

3
  • Thanks. Waiting for other inputs if any. If not, will accept your answer
    – ThomasG77
    Aug 7, 2021 at 19:16
  • I'm proud to answer at one of your very rare questions ! Aug 7, 2021 at 19:57
  • 2
    For multiple replacements, I prefer if("your_field_of_values" IN (-9999, 0), NULL,"your_field_of_values") Here I use 0 but it could be any value and the list could be longer or I could use a more complex condition e.g something like if("your_field_of_values" = -9999 OR "your_field_of_values" < 0, NULL,"your_field_of_values")
    – ThomasG77
    Aug 8, 2021 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.