I have looked at many threads on here asking about coding nested if-then or conditional statements in field calculator in ArcGIS. This seems to be a common problem for beginner programmers. I've attempted to learn some Python and I really wanted to figure this out myself, but am apparently failing.
The Problem: I have 3 columns (a,b,c) that have numeric values. I want a statement to assign them a value based on their numeric values > 0. For example, If a>0, then 1 and if b>0, then 2, and if c>0 then 3. There may or may not be a situation where 2 columns > 0 and I'm not sure how to deal with that.
I've tried variations of the code below. My errors are incorrect syntax on line 1. Am I using an incorrect function? I can't find any sites listing Python functions that include half of what I see people using here. Am I referencing the wrong columns or the columns incorrectly? I my spacing wrong?
Pre-Logic Script
def Calc( Cockle, Butter, Gaper)
if Cockle >0:
return 1
elif Butter >0:
return 2
elif Gaper >0
return 3
else 0
ClamType (new field) =
Calc(!Cockle!, !Butter!, !Gaper!)
I tried function Reclass. What am I missing?