I'm using a shapefile of different vegetation and land cover types and I want to generalize to a simpler classification (ie. I only need to differenciate between young and old forest and open land, human structures and water bodies). My current shpe contains a lot of information on stand type, density, height, disturbance, etc. So I'm trying to calculate a new field value from many existing fields in ArcGIS.

I want the new values to appear in the column "PER_AN_ORI".

I need to reclassify using a priority, ie. if field "perturbation" has a value X or Y, then give it the new value A or B. If that field is empty (or doesn't have the specified values), I want ArcGIS to look in the next priority field "TER_CO" and depending on what's there, give the new value C or D. Then look into field "type"... And so on.

Can I do this with Field Calculator. Do you recommend VBA or Python? I know neither, so a reference to a quick learning guide would be useful.

Attribute table extract


2 Answers 2


if/elif statements in python will do this for you. In your field calculator, select Python as your parser. In your code block, input something like this:

def newFieldVal (Perturbation, TER_CO...):
    if Perturbation == "X":
        return Perturbation
    elif Perturbation == "Y":
        return Perturbation
    elif TER_CO == "Q":
        return TER_CO

Where I have ... in the first line, input variable names of your choice (here I just use the name of the fields), separated by commas, between the parentheses. You can then write as many elif statements to achieve your desired hierarchy of values.

Then in your field calculator box input newFieldVal (!Perturbation!, !TER_CO!...), where the values in the parentheses are the list of fields corresponding to their order in the first line of your Codeblock, separated by commas.


Often times when it looks like I would wind up with a complex set of if/then clauses in a field calculator expression (which can be trouble because of the limited debugging), instead I'll just do a series of this -

  1. Select certain rows by using Select by Attributes. For example, select all rows where 'perturbation = "X"'
  2. Use Field Calculator to set a value to a particular column. e.g. "PER_AN_ORI" = "A" Field Calculator by default operates only on selected rows.
  3. Verify. This method has the added benefit of being easy to visualize the changes you are making.
  4. Repeat steps 1-3 until you've got all values filled in for "PER_AN_ORI"

No scripting required.

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.