Conditional (if, then) replacement of observations in a field in an attribute table with another value in ARC GIS Pro

1045
3
Jump to solution
10-29-2021 11:01 PM
Labels (2)
Hope-Hauptman
New Contributor III

I have an attribute table with a column that has many observations below a chemical detection limit - 0.005. Since these are not valid measurements, I would like to replace all values in the field under 0.005 with the value 0.0025. So: if an observation < 0.005 then replace with it 0.0025.

On a related note, for this same field there are some missing values which I would like to drop entirely. So something like: if NA, then omit

I am not familiar with python coding. I have tried calculate field and then arcade reclassify function as follows (does not work - I think it is the wrong function for conditional replacement). 

// Reclassify values to another value
function Reclass($feature.MEAN_RESULT) {
if ($feature.MEAN_RESULT < 0.005)
return 0.0025)
}

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

python parser.... you can arcade the idea if needed

# to call the def use
# r[!YourFieldNameHere!] like below
# r[!MEAN_RESULT!]

a = [0.1, None, 0.004]  #emulate a field
# just copy the function below
def r(fld):
    if fld is None or fld >= 0.005:
        return fld
    elif fld < 0.005:
        return 0.0025
        
# test the result

[r(i) for i in a]
[0.1, None, 0.0025]

... sort of retired...

View solution in original post

3 Replies
DanPatterson
MVP Esteemed Contributor

python parser.... you can arcade the idea if needed

# to call the def use
# r[!YourFieldNameHere!] like below
# r[!MEAN_RESULT!]

a = [0.1, None, 0.004]  #emulate a field
# just copy the function below
def r(fld):
    if fld is None or fld >= 0.005:
        return fld
    elif fld < 0.005:
        return 0.0025
        
# test the result

[r(i) for i in a]
[0.1, None, 0.0025]

... sort of retired...
Hope-Hauptman
New Contributor III

Worked perfectly - much thanks!

0 Kudos
ElishaBeckie1
New Contributor

Dan, Can you help me formulate what I can put in to create a new field from an existing field information, in the VRI type data.

So I want "TM" and "TB" from the BCLCS_4 column  to show as HWD in the new SPREADTYPE column.

Does that make sense? Can you help me please? I have very little python coding experience.

0 Kudos