Thanks. I re do and be more careful next time....
You're not using 50%. You're using modulo 50; the modulo operator is the % sign in Python. It's like regular division, except it gives you the remainder.
Primarily though, you need parentheses around the field name in the first line - def FindLabel([Contour]):
You also need to see whether the expression if [Contour] % 50 == 0: You left the 0 out above.
this did not work:
I used 50% since I want to label every 50' contour
tried it without brackets around Contour also but it didn';t work.
Siran,
To label numbers divisible by 100, use the modulo operator. In the label expression advanced box, set the parser to Python. Then use a function like below:
def FindLabel(somefield):
if somefield % 100 == 0: return somefield
if you want to label with a different field based on somefield:
def FindLabel(somefield, anotherfield):
if somefield % 100 == 0: return anotherfield
I need assistance with labeling also. I am new to Python and I may have posted this but I am going to try to get your assistance on this since I've been reading your answers to this string from Barton.
I am trying to label contours that are designated as "major" which are the rounded number in the values fields--300, 350, 400, etc. and not label all of the contours. I've been in the Python mode, advanced checked in the label expression dialog box but how do I Find a label in one field and label it some value from another field? Is this possible?
def FindLabel ( [PARCEL] , [LOTNUMBER] , [DEEDACRES] ): if not [LOTNUMBER]: return "<CLR yellow='255'>" + [PARCEL] + "</CLR>\n" + str([DEEDACRES]) else: return "<CLR yellow='255'>" + [PARCEL] + "</CLR>\n" + [LOTNUMBER]
def FindLabel ( [contractorName] ): if not [contractorName]: a = "Apples" else: a = [contractorName] return a
def FindLabel ( [PARCEL] , [LOTNUMBER] , [DEEDACRES] ): if [LOTNUMBER].strip() == None: return "<CLR yellow='255'>" + [PARCEL] + "</CLR>\n" + str([DEEDACRES]) else: return "<CLR yellow='255'>" + [PARCEL] + "</CLR>\n" + [LOTNUMBER]
def FindLabel ( [PARCEL] , [LOTNUMBER] , [DEEDACRES] ): if long([LOTNUMBER]) >1: return "<CLR yellow='255'>" + [PARCEL] + "</CLR>" + '\n' + str([LOTNUMBER]) else: return "<CLR yellow='255'>" + [PARCEL] + "</CLR>" + '\n' + str([DEEDACRES])
def FindLabel ( [NAME], [ID] , [RECHAR] ): if long( [RECHAR].split('-')[0] )<=80000: return "<CLR yellow='255'>"+ [RECHAR] + '\n' + [NAME] + "</CLR>" elif long( [RECHAR].split('-')[0]) > 80000: return "<CLR yellow='255'>"+ [NAME] + '\n' + str( [ID] ) + "</CLR>"
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.