Is it possible to label a feature in ArcMap using geometry values?
In this instance I want to label features (polylines) with the Live Z value of the last vertex obtained from the Shape.
However when I try something simple like the XMin of the extent of the shape:
It returns an error:
Is it possible to use the features' geometry to formulate a label? I do not want to calculate values from the geometry into a field and then label that field unless I absolutely have to:
Ideally the label should be live, changing as the feature is modified.
Based on the answer by Felix:
def FindLabel ( [OBJECTID] ):
mxd = arcpy.mapping.MapDocument("CURRENT")
layers=arcpy.mapping.ListLayers(mxd, "WatrcrsL")
lr=layers[0]
with arcpy.da.SearchCursor(lr, 'Shape@','OBJECTID = '+str( [OBJECTID] )) as cursor:
for row in cursor:
a=row[0].lastPoint.Z
return a
Will label the features with the last points' Z value live!
Answer
Example for point layer
def FindLabel ( [FID] ):
mxd = arcpy.mapping.MapDocument("CURRENT")
layers=arcpy.mapping.ListLayers(mxd, "ac_pipes_aspoints")
lr=layers[0]
with arcpy.da.SearchCursor(lr, 'Shape@XY',r'"FID"='+str( [FID] )) as cursor:
for row in cursor:
a=row[0]
return a[0]
No comments:
Post a Comment