mardi 30 mai 2017

ArcGIS 10.2 Python code block: indentation error

I have an attribute table with a GRIDCODE column that only has values 1, 2 or 3. I need my new field to be either A, B or C depending on the value of GRIDCODE. The attribute table has thousands of features so doing the selection by attributes would be tiresome.

I tried the following code but I keep getting error 000989 : Python syntax error: . So apparently my code has improper syntax. I've tried the following:

def yieldCalc(value):
 if (value=1):
     return 6.2
  elif (value=2):
     return 7.9
  else:
     return 8.21

Also

def yieldCalc(value):
 if (value=1):
     return 6.2
  elif (value=2):
     return 7.9
 else:
     return 8.21

And

def yieldCalc(value):
 if (value=1):
     return 6.2
 elif (value=2):
     return 7.9
 else:
     return 8.21

What is the proper way to indent the python code block in Arcmap?

Many thanks

Aucun commentaire:

Enregistrer un commentaire