2

Is it posible to use a wildcard in a field with real values? I am using QGIS.

For example. I have a field with values from 0 to 10000, with increments of 10 metre, but would only like to display every 100 or 200 metre value. ie 100, 200, 300, 400 etc.

It can be done if the field is a text field, but I don't want to add a additional field.

In the expression in the image below, the "CHGE_TEXT" field, is a text field. I would like that to work with a real field.

enter image description here

5
  • 6
    In QGIS expression, this could be done with the modulo operator "%". Round("field", 0) % 100 = 0. This returns true for all doubles like 100.00, 100.20, 200.3333, 9900.9999. The modulo operator should be available in any GIS software.
    – ThiPa
    Mar 29, 2022 at 6:03
  • 1
    Depending on the data source, you can convert the field to text and then apply the like operator. Ex for Postgres: num_val::text like '1%0' (start with a 1 and ends with a 0)
    – JGH
    Mar 29, 2022 at 13:07
  • I was just able to use the like operator with the % wildcard to select features with lengths ending in two numbers, but the same expression failed in the definition query. 3.24.1
    – John
    Mar 29, 2022 at 13:58
  • 1
    @ThiPa looks like a good approach - a filter such as "fieldname" % 100 = 0 for 100m intervals and "fieldname" % 200 = 0 for 200m intervals.
    – Aquamarine
    Mar 29, 2022 at 18:31
  • 2
    @ThiPa you should post your modulo solution as an answer
    – J.R
    Mar 29, 2022 at 21:26

1 Answer 1

2

In QGIS expression, this could be done with the modulo operator "%".

Round("field", 0) % 100 = 0

This returns true for all doubles like 100.00, 100.20, 200.3333, 9900.9999. The modulo operator should be available in any GIS software.

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.