7

I’ve created a feature class with a one to many relationships to a table.

One point many classes.

However I want to label the point with the classes attributes.

Esri wrote VB solution but it's not supported at version 10.1.

0

1 Answer 1

8

i found the answer here at wolf mapper blog - right click on the point shapefile and select “Properties” > “Labels” tab > “Expression…” button. In the “Label Expression” window select “Python” as the “Parser:” and click the check-box next to “Advanced.” Insert the following code:

    def FindLabel ( [LocID] ):

   import arcpy
   myDataTable = "data table" #insert data table name
   myComponent = "Arsenic" #insert component name
   myScreeningLevel = "32" #insert exceedance  level
   myQuerySelect = '"location_id"' + " = '" + [LocID] + "' and " + '"component"' + " like '" + myComponent + "%'"
   myFieldsQuerySelect = "OBJECTID; location_id; component; top_depth_inches; bottom_depth_inches; result; units"
   mySortQuerySelect = "top_depth_inches"
   myText = ""

   mxd = mxd = arcpy.mapping.MapDocument("CURRENT")

   for table in arcpy.mapping.ListTableViews(mxd):
     if table.name == myDataTable:
       rows = arcpy.SearchCursor(table, myQuerySelect, "", myFieldsQuerySelect, mySortQuerySelect)
       myText = "<BOL>" + [LocID] + "</BOL>\n" + "<ITA>" + myComponent + "</ITA>" + "\n"
       currentState = ""
       for row in rows:
         if currentState != row.OBJECTID:
           currentState = row.OBJECTID
         if float(row.result) >= float(myScreeningLevel):
           myText = myText + str(int(row.top_depth_inches)) + '&quot;-' + str(int(row.bottom_depth_inches)) + "&quot; <BOL><CLR red = '255'>" + str(row.result) + "</CLR></BOL> " + str(row.units) + "\n"
         else:
           myText = myText + str(int(row.top_depth_inches)) + '&quot;-' + str(int(row.bottom_depth_inches)) + '&quot; ' + str(row.result) + " " + str(row.units) + "\n"

       return myText
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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