he encontrado la respuesta aquí en el blog de wolf mapper - haga clic con el botón derecho del ratón en el shapefile de puntos y seleccione "Propiedades" > pestaña "Etiquetas" > botón "Expresión ". En la ventana "Expresión de la etiqueta" seleccione "Python" como "Parser:" y haga clic en la casilla de verificación junto a "Avanzado". Inserte el siguiente código:
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)) + '"-' + str(int(row.bottom_depth_inches)) + "" <BOL><CLR red = '255'>" + str(row.result) + "</CLR></BOL> " + str(row.units) + "\n"
else:
myText = myText + str(int(row.top_depth_inches)) + '"-' + str(int(row.bottom_depth_inches)) + '" ' + str(row.result) + " " + str(row.units) + "\n"
return myText