Saturday, 19 August 2017

Conditional Statement in QGIS Field Calculator


I'm using QGIS to calculate total loss in an earthquack attack. I wrote this expression in Field Calculator.


CASE 
WHEN "build_type" = 1 AND "MMI" < 5 THEN "perc_loss" = 0
WHEN "build_type" = 1 AND (5 >= "MMI" AND "MMI" < 6) THEN "perc_loss" = 20
WHEN "build_type" = 1 AND (6 >= "MMI" AND "MMI" < 7) THEN "perc_loss" = 28
WHEN "build_type" = 1 AND (7 >= "MMI" AND "MMI" < 8) THEN "perc_loss" = 33
WHEN "build_type" = 1 AND (8 >= "MMI" AND "MMI" < 9) THEN "perc_loss" = 35

WHEN "build_type" = 1 AND (9 >= "MMI" AND "MMI" < 10) THEN "perc_loss" = 71
WHEN "build_type" = 1 AND "MMI" >= 10 THEN "perc_loss" = 95 END

There's no error/invalid warning, but no value resulted. Is there any wrong syntax I used? Anyone can help please? :)



Answer



I think it should be


CASE 
WHEN "build_type" = 1 AND "MMI" < 5 THEN 0
...


without the "perc_loss" = part


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...