I understand this can easily be done manually using Calculate Field, however I'm looking to automate this process using ModelBuilder as it is a requirement of the current module.

I have 7 Weather columns in my soils feature class table, X Dry, Dry, Moist, Wet, X Wet, Frozen & X Frozen. The values of these fields are either GO, Restricted, Severely Restricted or Unknown. However they have purposely been assigned different values, so when being converted from a polygon to a raster Go should = 0, R = 1, SR + Unk = 2, but they don't all read like that when making it a Raster, giving me false outputs on my CCM analysis. I need to pre-engineer the soils data before bringing it into a raster calculator.

I have run a Calculate Field using Python:


def Reclass(field):
  if field =='GO':
    return 0
  elif field == 'R':
    return 1
  elif field == 'SR':
    return 2
  elif field == 'UNK':
    return 2    

This gives me my desired output (see attached image) however it will only run for the one Field. I have tried using ArcGIS Pro's Iterate functions but I cant seem to figure out how to get it to run for all 7 of the weather conditions without adding 7 field calculators to my model which I do not want to do.

Currently it is just replacing the values in the attribute table but if it is easier new fields can be added to populate the 0/1/2 values in.

Soils Attribute Table


2 Answers 2


No Python code is required and this can be done in model builder in ArcPro using the Fields Iterator. You need to be using at least ArcPro 2.6; earlier versions do not have this iterator.

The model is simply this:


The iterator filters the required fields and the calculate field tool is set up as is:

Calculate Field

Note: I had renamed the output of the iterator to "myField", the default name is a generic "Value", just makes things clearer as to what the object is.

Note: be aware such a model could not be shared and used in ArcMap as the iterator does not exist in ArcMap

  • 1
    Oh I didnt know it existed, nice!
    – BERA
    Jul 8, 2021 at 10:21
  • 1
    @BERA there is also the Layers Iterator that has crept in since ArcPro 2.7 but that seems flaky as the only time I tried to use it, it didn't work, so I gave up and went the Python way. :)
    – Hornbydd
    Jul 8, 2021 at 13:39
  • Thankyou! sorry for the late reply, we moved over to MCA but I'm back on CCM now. Your images made perfect sense and I understand the concept of how it works, however when I run the calculate field it only seems to run 1 of the "iterate Fields" the one that is displayed in value, is there something I'm missing? Jul 13, 2021 at 15:50

Couldn't attach an image to the comment so I've posted it here instead This is the picture of my current model

  • I would start with the nullable error and make sure that field is nullable. You might have to create a new featureclass making sure that property is nullable.
    – Hornbydd
    Jul 13, 2021 at 17:39
  • I think that dataset was just shite tbh, on my summative now and I did exactly the same process and it worked first time no issues whatsoever, and yeah I did try changing it to allow null values but everything about the data was locked, I couldn't change anything. Figured out the issue with it only running one field calculator, I just needed to add a precondition to the iterator, but thankyou for all the help, much appreciated!! Jul 14, 2021 at 16:30
  • Yes a weirdness of model builder is that it will run tools in the order they are added to the model canvas so setting the precondition is a way of enforcing order of sequence.
    – Hornbydd
    Jul 15, 2021 at 0:00

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.