python label expression does not filter labels

406
2
Jump to solution
12-19-2013 05:49 AM
SWCASWCA
New Contributor III
I have a taxlot layer with a numeric (double) field called GIS_ACRES. I only want to label those features that are greater than 1 acre in size. I am using this expression:

def FindLabel ( [GIS_ACRES], [TLID]  ):   if ( [GIS_ACRES]  > 1 ):     return [TLID][-5:]   else:     return ""


also tried if ( [GIS_ACRES] ) > 1:
makes no difference.

It labels ALL taxlots, regardless of size. Why doesn't it work? What syntax am I missing? I get no errors, just doesn't filter.

I recently installed 10.2 over 10.1. Should I also have updated something related to Python?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JoshuaChisholm
Occasional Contributor III
Hello SWCA,

It seems like python isn't recognizing your [GIS_ACRES] field as a double field (or even as a number). To get around this you can convert it to a float. It's also probably a good idea to compare it to another float (1.0 instead of 1).

def FindLabel ( [GIS_ACRES], [TLID]  ):   if ( float([GIS_ACRES])  > 1.0 ):     return [TLID][-5:]   else:     return ""


Let me know how it goes,
Good luck!

View solution in original post

0 Kudos
2 Replies
JoshuaChisholm
Occasional Contributor III
Hello SWCA,

It seems like python isn't recognizing your [GIS_ACRES] field as a double field (or even as a number). To get around this you can convert it to a float. It's also probably a good idea to compare it to another float (1.0 instead of 1).

def FindLabel ( [GIS_ACRES], [TLID]  ):   if ( float([GIS_ACRES])  > 1.0 ):     return [TLID][-5:]   else:     return ""


Let me know how it goes,
Good luck!
0 Kudos
SWCASWCA
New Contributor III
That worked great! Thanks!
0 Kudos