New answers tagged

4

You should always check to see that Calculate Field functions return a value in all possible condition paths. One way to do this is to use a code pattern that initializes the return value and uses if statements to alter it before a singleton return: def reclass(key_biomec, historical): result = key_biomec if (historical == 'Historical Survey'): ...


4

Your code must be like below: Expression line: reclass(!Historical!) def reclass(Historical): if (Historical == 'Historical Survey'): return 'Null' else: return Historical


1

You don't do it with an if, you do it by computing both and selecting one vs the other with a where() statement. result1 = image.expression('(A1-B1) / (C1-D1)...') result2 = image2.expression('(A2 - B2) / (C2-D2)...') result = result1.where(e.lt(0.78), result2)


Top 50 recent answers are included