2

In an elevation file I want to find all the 5m contours and mark a column up as major. This has to be done in QGIS in the field calculator or modeler.

I want to do something like the following based on this post

CASE WHEN "elevation" %% 5 THEN 'major' WHEN "elevation" %% 1 THEN "moderate" ELSE "Minor" END 

But this doesn't work -

Parser Error: syntax error, unexpected MOD

Eval Error: No root node! Parsing failed?

Ideally I want to run it as part of the following (which works but level 50 includes 1m and 5m contours)

CASE WHEN "contour_level" = 48 THEN 'minor' WHEN "contour_level" = 49 THEN 'minor' WHEN "contour_level" = 50 THEN 'moderate' ELSE 'Check' END 
9
  • 2
    You've tagged "python" in this question, but your code looks nothing like python. Commented Nov 12, 2015 at 4:13
  • If it does get through to Python then the modulus operator is % rather than %%. Commented Nov 12, 2015 at 4:18
  • @Fezter -it is python within qgis modeler Commented Nov 12, 2015 at 4:22
  • @PolyGeo I tried with % as well, both give the same error. Commented Nov 12, 2015 at 4:23
  • 2
    @GeorgeC - Awesome, glad you got it working! Thanks but I will let you post the answer :) Commented Nov 13, 2015 at 10:28

1 Answer 1

3

Based on the reply from @Joseph, I found that the following worked.

I needed 1m and 5m intervals not just 1m and 5m lines. I ended up with

[[CASE WHEN "elevation" % 1 THEN 'minor' WHEN "elevation" % 5 THEN 'moderate' ELSE 'major' END]] 
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.