AnsweredAssumed Answered

Error Labelling Features Using Basic Python

Question asked by ben_vk on Mar 8, 2015
Latest reply on Mar 8, 2015 by ben_vk



I am using the below code to label contours of a small area. Due to laziness and simplicity, this polyline featureclass has both the contours AND pipes together, but they are easy to identify, as all pipes have a description in the notes field, and they have NULL in the elevation field, and visa versa.


Due to these fields being this way, I am hoping to setup a simple python script to label the contours with ELEVATION and pipes with NOTES attribute.


I have my code working 99%, but as the contours are so close together I want to only show every 2nd line, so they are all contours with elevation / 0.5 with no remainder.

EG it would only return these: 150.00  150.25  150.50  150.75  151.00 151.25......


This code is giving me an error:

def FindLabel ( [ELEVATION], [NOTES] ):
  el = [ELEVATION]
  nt = [NOTES]
  if el > 0:
    if (el%0.5)==0:
      return el # returns the elevation as it contains a value
    return nt # returns [NOTES] as label



2015-03-09_14-41-03_Weave_Alternate.mxd - ArcMap.jpg


I can remove the line 'if (el%0.5)==0:' and it works fine (just a bit messy). So i know this line contains the problem.


Can anyone tell me where I have gone wrong please?