I have a feature class in a personal geodatabase with 2 fields. They both have domains set up to ease the editing process for my users. If my WaterType field is set as "Not Irrigated" (or code 4) then I need my IrrigType to be set as "Not Irrigated" (code 0). I'm not sure if I want to use the description or the code for the domains.

I would also like to set this up so that it runs automatically...so that I don't need to calculate field and run the Python script every time.

Any suggestions? I tried the following code to no avail:

def calIrrigType(WaterType, IrrigType):
  if WaterType=='Not Irrigated':
    return 0
  return IrrigType
  • 2
    Check the indentations in the if/else statements--they appear unequal. – Aaron Oct 31 '13 at 16:57
  • I may have an old script that does something similar ill have to see if I can find it and ill post it. – landocalrissian Oct 31 '13 at 17:40

In addition to Aaron's comment, once the code is working, I would suggest the following to automatically run the data update:

  1. create a model using the Calculate Field tool
  2. export it out to python script
  3. call the script to run from a .bat file
  4. schedule the .bat to run from e.g. Windows scheduler.
| improve this answer | |
  • 2
    +1 but you should normally be able to call the *.py to run direct from the Windows Scheduler without wrapping it in a *.bat. – PolyGeo Oct 31 '13 at 18:12
  • ok, good to know! – artwork21 Oct 31 '13 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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