1

I am trying to calculate a field (NAT_RE_MI) by simply adding three other fields (FOR_FISH, MINING, FARM_EMP) together.

Some of the fields have a no data value of -98 or -99.

What code would I use to exclude those from the calculation in the Field Calculator for ArcGIS Pro?

Midavalo
30k11 gold badges53 silver badges108 bronze badges
asked Jul 18, 2016 at 16:07

1 Answer 1

2

Use an if to check the value of each field, and skip that value if it's one of your "no data" values. You can add other "no data" values to the no_data list to skip those as well.

Expression:

skip_nodata(!FOR_FISH!, !MINING!, !FARM_EMP!)

Code Block:

def skip_nodata(val1, val2, val3):
 no_data = [-98, -99]
 x = 0
 if val1 not in no_data:
 x += val1
 if val2 not in no_data:
 x += val2
 if val3 not in no_data:
 x += val3
 return x

enter image description here

enter image description here

answered Jul 18, 2016 at 19:38
0

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.