1

SOLUTION: I was able to do it with help of a colleague by creating a list instead, I'm assuming the tuple was was a quirky bug;

def FindLabel ( [PIPE_INTERNAL_DIAMETER] ):
lst = ['1"', '2"']
if [PIPE_INTERNAL_DIAMETER] not in lst:
return [PIPE_INTERNAL_DIAMETER]
else:
return None

I feel like this should be straight forward but it's turning out to be a pain.

Basically, I have a line feature in ArcMap that has a field (size) that is type double.

I wanted to create a label that would exclude all sizes below 2 (2"). Problem is because the field is based on a domain the field value is 2 but to do the python labeling it seems like they are strings (2 equates to 2" in the domain).

I figured I'd just create a label like this following:

def FindLabel ( [PIPE_INTERNAL_DIAMETER] ):
if [PIPE_INTERNAL_DIAMETER] in ('1"', '2"'):
return [PIPE_INTERNAL_DIAMETER]
else:
return None

and only show the diameter values I wanted to show. The problem is it works fine with those two values (1" and 2"); enter image description here

but as soon as I add another value I am getting an error;

enter image description here

I know I could do this fairly easily in a label class but I feel like this should be straight forward to do in a python label too so its kind of bothering me that I cant figure it out. Might anyone shed some light on this for me?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jun 8, 2023 at 17:46
1
  • 2
    Please don't include answers (solutions) within the area reserved for questions. There is a separate area reserved for answers. Commented Jun 9, 2023 at 4:58

1 Answer 1

0

You could convert the value into an integer and then compare it with math operations.

def FindLabel ( [PIPE_INTERNAL_DIAMETER] ):
 if int([PIPE_INTERNAL_DIAMETER][:-1]) >= 2:
 return [PIPE_INTERNAL_DIAMETER]

Much effective, you may have 100 values. What you are gonna do, create a list with 100?

answered Jun 9, 2023 at 8:19

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.