Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
1  
Not sure but you can convert your VB code to Python and then check in 10.1 ( In ArcGIS 10.1 Python scripting is works great). Following is the link for vb to python :stackoverflow.com/questions/449734/… –  Sunil Feb 6 '13 at 7:12
2  
I found solution at wolf mapper blog link –  Geog Jun 2 '13 at 19:41

1 Answer 1

up vote 4 down vote accepted

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
share|improve this answer
    
Really curious how the performance is when using this approach...? –  brichins Oct 8 at 16:37
1  
I've used it at a script that produced maps and I had to add a long delay in order to get all the labels appear –  Geog Oct 29 at 20:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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