I'm trying to reclass 3000, 2000, 1000 and 0.5 into 1, 2, 3 and 4 respectively in a new field using field calculator. However it keeps returning an error message and I can't figure out why, any ideas?
def Reclass( !BUFF_DIST! ):
if !BUFF_DIST! = 3000:
return 1
else if (!BUFF_DIST!) = 2000:
return 2
else if (!BUFF_DIST!) = 2000:
return 3
else:
return 4
Answer
Use Python parser and call the function with the actual field name enclosed in !!. BUFF_DIST=
Reclass(!BUFF_DIST!)
When you define the function use whatever name you want, for example buffdist. Also change = to == and else if to elif. Pre-Logic script code:
def Reclass( buffdist ):
if buffdist == 3000:
return 1
elif buffdist == 2000:
return 2
elif buffdist == 1000:
return 3
else:
return 4
No comments:
Post a Comment