5

I have a geopackage file which contains point data with a column of 'depth of cover' and score.

In the score column I am using the field calculation to create an expression so that any number less than 0.5 in the depth of cover column would be represented as a 1 and anything in between 0.6 to 5.0 would be represented as a 2, and anything greater than 5.1 would be a 3 in the score column.

This is the expression I have used:

CASE
  WHEN  "Depth of cover" <=0.5 THEN 1
  WHEN  "Depth of cover" >=0.6 <=5.0 THEN 2 
  WHEN  "Depth of cover">=5.1 THEN 3
END

I can get the 1 and 3 values to work but not 2. I know I have the expression wrong at this point because I'm doing a range rather than a less than or greater.

Following on from this if I wanted to change the 1 to a High 2 to medium and 3 to Low how would I do this as I get Column 'High' not found.

2
11

Try this (I correct bounds too) :

CASE
 WHEN "Depth of cover" <= 0.5 THEN 1
 WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 2
 WHEN "Depth of cover" > 5.0 THEN 3
 ELSE NULL
END

For the second part, create a string field and update it with :

CASE
 WHEN "Depth of cover" <= 0.5 THEN 'High'
 WHEN "Depth of cover" > 0.5 AND "Depth of cover" <= 5.0 THEN 'Medium'
 WHEN "Depth of cover" > 5.0 THEN 'Low'
 ELSE NULL
END

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.