HOW TO

Obtain X and Y values of label points

Last Published: April 26, 2020

Summary

This article discusses several methods for obtaining the XY values of label points depending on how the labels were generated.

Procedure

  • Return feature centroids and add the result to the attribute table. The auto-Label process places the label point at the polygons' area weighted centroid. You can return the centroid of a polygon to get the X and Y component of the label point. You can also use this method to return the centroid of coverage annotation feature class label.
    See: How To: Add the X and Y components of a polygon or coverage annotation centroid to fields in the attribute table
  • Return the location of coverage labelpoint features and add the results to the attribute table.
    See: How To: Add X and Y components of coverage labelpoint feature class to fields in the attribute table
  • Return the location of text labels.
    1. Paste the following code into a new script window and compile it.
      thegraphiclist = av.getactivedoc.getgraphics
      oneelement = thegraphilist.get(0)
      x_y = oneelement.getorigin
      msgbox.info(x_y.asstring,"")
    2. Open the view and make the theme with the labels active.
    3. Switch directly to the script windows and click the Run button.
      Note:
      This code returns the coordinates of the first text graphic in a message box. You can modify the script to loop through all labels attached to a theme and to populate fields in a table with the values.
      Note:
      The auto-label process anchors the lower left corner of the text at the polygon centroid. The first and last method will yield different results if you use the default lower left text placement option in the auto-label. 

Article ID:000003599

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic