Hello,
I need help with writing a function. I am trying to calculate the dollar per acre spending on some products. The data behind is from USDA's Cropscape data. Count is how many pixels you have in a defined area (30m x 30m) which I converted to acres without any hustle.
Now I am trying to write this, with my limited vba knowledge, but don't know how to
DollarPerAcre=
IF CLASS_NAME = Alfalfa
THEN Acres * 100
ELSE IF CLASS_NAME = *Wheat* (contains "Wheat" in it)
THEN Acres * 80
ELSE
0
I would appreciate any help
Solved! Go to Solution.
code block:
def get_factor(class_name):
if class_name == "Alfalfa":
return 100
if "Wheat" in class_name:
return 80
return 0
DollarPerAcre = get_factor(!CLASS_NAME!) * !Acres!
code block:
def get_factor(class_name):
if class_name == "Alfalfa":
return 100
if "Wheat" in class_name:
return 80
return 0
DollarPerAcre = get_factor(!CLASS_NAME!) * !Acres!