0

I am using ArcGIS Desktop 10.5 here. I have a streets layer that has address ranges in the fields FromLeft, ToLeft, FromRight, and ToRight. I am trying to create a street index csv that has the low and high values for each street. I'm trying to calculate the min and max values across the 4 fields and calculate those into 2 new fields called MIN and MAX.

I used min( !FromLeft!, !FromRight!, !ToLeft!, !ToRight!) to get the minimum values.

The only thing is that some streets have 0 in one or more of these 4 fields. I would like to skip the value 0 from this calculation and only consider non-zero numbers.

Can this be done using the field calculator?

All my fields are LONGs.

enter image description here

4

Maybe there are easier ways, but here's one using Python.

  1. In the Field Calculator window, select the Python parser
  2. Check Show Codeblock
  3. The Pre-logic Script code defines a method that returns only values greater than 0.
def greater_than_0 (value):
    return value > 0
  1. The code for the MIN field is
min (filter (greater_than_0, [ !FromLeft!, !FromRight!, !ToLeft!, !ToRight! ]))

Note that this code will fail if all fields contain 0 values. If you have those, you may want to make a feature selection to exclude those records first

Here's a screenshot (Never mind my fieldnames, I used a scrap shapefile)

Field calculator

1
  • Thanks! Worked like a charm. – Tigerwoulds Jul 15 '20 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.