I'm trying to populate a field from another. The catch is that it isn't 1 or 2 values. If my field A = 4 then I want it to return field B to 0. But if Field A is 1, 2 or 3 then I want the user to be able to use the domain drop down list to choose what field B is--because it could be one of 3 other values. Is that possible? Below is the code I think is a start. But I need it to return 1, 2 or 3 if WaterType = anything but 4.

def Reclass (IrrigType):
  if WaterType = 4:
     return 0
     return 1
  • This sounds more like you want to set up subtypes and attribute domains. If you set up a subtype on field A, then using an attribute domain the dropdown list in Field B would change accordingly. This would ensure that if NI is chosen, Non Irrigated is automatically populated, else the dropdown list will appear. Commented Nov 6, 2013 at 5:14

1 Answer 1


First of all, be sure to use == for comparison expressions instead of =, which is for assignment.

If I've understood correctly, you should be able to use:

def Reclass(WaterType): 
    if WaterType == 4: return 0
    else: return WaterType

or (in shorter form)

def Reclass(WaterType): 
    return 0 if WaterType == 4 else WaterType

This will return 0 if WaterType = 4. If WaterType != 4 then it will return whatever the value was.

Based on your comment, it sounds like your user is editing the features normally (using domains, etc) and you want to run a script at the end (ie. before posting or similar) to be sure that if WaterType = NI then IrrigType should also be NI otherwise leave what the user entered.

If that is the case, then you can use the below:

def Reclass(IrrigType,WaterType):
    if WaterType == 'NI': return 'NI'
    else return IrrigType

You'll run this to set the value of IrrigType, but you'll have to supply both the value of WaterType and the (current) IrrigType.

  • Maybe more detail will help. I have 12 water types in my WaterType field. I only care if one of them = NI (not irrigated). If the value in the WaterType field is NI then I want my IrrigType to return 'Not Irrigated." Otherwise if the WaterType is any of the other 11 values I want my user to use the dropdown list to pick a value for IrrigType.
    – bhoobler
    Commented Nov 5, 2013 at 17:45
  • 1
    @bhoobler Ok, just to be clear, what GIS/environment are you using? Commented Nov 5, 2013 at 18:01
  • 1
    You may have 12 water types in your field that you care about, but there is only one of them that may be automated using the if/then statement. The others cannot be automated because you have stated that you want people to choose the values from the pick list. The only other thing I can think of is that you want a script that not only fills the one value automatically, but brings up the pick list for each record of the other 11 values to let a user choose. If this is so, it seems rather inefficient. If not, I think we are missing something. Commented Nov 5, 2013 at 18:05
  • Thanks for your help. I'm not sure I have the skills here to ask the question correctly but I appreciate you trying. I am in 10.2. My user wants the IrrigType field to be calculated automatically with "Not Irrigated" if the value in the WaterType field is "NI." Otherwise....for example, if the WaterType field is "SW" they want to use the pick list from IrrigType. Basically they want to run a tool that auto populates IrrigType with Not Irrigated. Just something that will save them some time and make sure that if WaterType = NI then so is the IrrigType.
    – bhoobler
    Commented Nov 5, 2013 at 18:20
  • def Reclass(IrrigType): if WaterType == NI return "Not Irrigated" else: return IrrigType
    – bhoobler
    Commented Nov 5, 2013 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.