1

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

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 30, 2014 at 19:20
2

2 Answers 2

3

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
 elif...

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.

answered Dec 30, 2014 at 19:34
2

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.

answered Dec 30, 2014 at 19:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.