In QGIS I have the following script that evaluates the results in each feature then gives it a value. Some of the values are NULL
, which is fine, but how do I get the Advanced Python field calculator to deal with it?
I get the following error that I think is due to my NULL
syntax:
FieldPyculator code execute error. Global code block can't be executed! SyntaxError invalid syntax (, line 4) Execution failed after 0.02 seconds
def getValue(distance, SPECIES_NM, F_SEN_ZN_1):
if distance == None:
value = 0.50
elif SPECIES_NM is not None AND F_SEN_ZN_1 == 'No' AND distance <= 100:
value = 0.75
elif SPECIES_NM is not None AND F_SEN_ZN_1 is None AND distance <= 100:
value = 0.50
elif SPECIES_NM is not None AND F_SEN_ZN_1 = 'No' AND distance <= 100:
value = 0.50
elif SPECIES_NM is None AND F_SEN_ZN_1 = 'Yes' AND distance <= 100:
value = 1.0
elif SPECIES_NM is not None AND F_SEN_ZN_1 = 'Yes' AND distance <= 100:
value = 1.0
elif distance is None and distance > 100:
value = 0.50
elif SPECIES_NM is not None AND F_SEN_ZN_1 = 'No' AND distance > 100:
value = 0.50
elif SPECIES_NM is not None AND F_SEN_ZN_1 is None AND distance > 100:
value = 0.50
elif SPECIES_NM is not None AND F_SEN_ZN_1 = 'No' AND distance > 100:
value = 0.50
elif SPECIES_NM is None AND F_SEN_ZN_1 = 'Yes' AND distance > 100:
value = 0.75
elif SPECIES_NM is not None AND F_SEN_ZN_1 = 'Yes' AND distance > 100:
value = 0.75
else:
value = -0.999999999
return value
and then calling the function
value = getValue(<distance, SPECIES_NM, F_SEN_ZN_1>)
getValue(<distance, SPECIES_NM, F_SEN_ZN_1>)
withgetValue(<distance>, <SPECIES_NM>,<F_SEN_ZN_1>)