I would like to do a simple calculation using VB script or Python. Here is a screenshot of my field calculator which continuously seems to run into errors. Basically for the SITE CLASS field I would like to assign all the ST as "Optimal", all the WT as "Subsuitable" and all the CT as "Unsuitable".
-
1Can you edit your post to include all the text in the Pre-Logic Script Code box? Right now it's getting cut off, so it is hard to see what you are currently doing.– ycartwhelenSep 8, 2021 at 12:58
-
3(You should always try to add the code as text instead of screenshots of it, see: stackoverflow.com/help/minimal-reproducible-example)– BERASep 8, 2021 at 13:21
1 Answer
I think you are mixing SQL, VB and python syntax. Use python parser and:
Pre-Logic:
def reclass(siteclass):
if 'ST' in siteclass:
val = "Optimal"
elif 'WT' in siteclass:
val = "SubSuitable"
else:
val = "Unsuitable"
return val
Call with
MACSITE_CL=
reclass(!SITE_CLASS!)