0

I filtered my attribute table to get only some objects (here is my filter:

"Code_12" BETWEEN '211' AND '243') but I see on my attribute table that I have selected only some objects on the objects already filtered (see screen capture). I do not know why. I need to make fragmentation calculations on my attribute tables after applying filters for each type of land covers but my results are odd so i was wondering if this could not be a reason. Does someone knowenter image description here ?

8
  • 1
    your expression does not fit as a filter in the attribute table, I suggest you create a new field "Code_12_bis", define it numeric and populate it with to_int ("Code_12"), then apply the filter "Code_12_bis">= 211 AND "Code_12_bis"<= 243
    – pigreco
    Commented Mar 14, 2022 at 9:13
  • 1
    Why not directly ` "to_int(Code_12")>= 211 AND to_int(Code_12")<= 243` ?
    – JB D
    Commented Mar 14, 2022 at 9:21
  • 1
    Your "Code_12" seem to be text field and text field doesn't always behave like numeric field with comparaison operator, try the other comments suggestion for better results
    – J.R
    Commented Mar 14, 2022 at 9:45
  • Hi, sorry but not sure to get it with this one : "to_int(Code_12")>= 211 AND to_int(Code_12")<= 243` it feels that the ponctuation is strange... can you rewrite it ? thanks a lot!
    – Robagb
    Commented Mar 14, 2022 at 10:10
  • Also QGIS says to me "to_int" is not defined...
    – Robagb
    Commented Mar 14, 2022 at 10:14

1 Answer 1

1

The Code_12 field looks textual and therefore the rules of numeric fields do not apply, so you have to transform it into an entire field, for example by adding a virtual field (which does not physically modify your table), steps:

  1. add a virtual field Integer 32, length 9;
  2. populate it with the expression to_int ("Code_12");
  3. apply the filter "Code_12_bis">= 211 AND "Code_12_bis"<= 243

step 1:

enter image description here enter image description here

step 3:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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