English

How To: Rotate point labels by an attribute field and offset them so that labels are placed on top of the points

Summary

If you have ArcGIS version 8.2 or later, you can rotate dynamic point labels in ArcMap based on a rotation field, while also offsetting those labels so the text appears directly on top of the point features.

A common scenario where you might want to do this is to label parcels on a parcel map. Parcel labels are typically rotated to follow the long direction of the parcel polygons. Since you can only rotate labels for point features in ArcMap, an extra step is required if you want to label polygon or line features.

Procedure

You must have ArcGIS version 8.2 or later to rotate labels using field values.

  1. Add a point layer in ArcMap with at least one field you wish to label, and another field populated with the angles used to rotate your labels. If this is already done, skip ahead to Step 4.
  2. It is only possible to rotate labels for point features. Create a new point layer based on polygon centroids or line midpoints.
    <a href='http://support.esri.com/en/knowledgebase/techarticles/detail/21473' target='_blank'>How To: Use ArcObjects to get the x and y coordinates of points, polygon centroids, or line midpoints</a>
  3. Create a new XY point layer in ArcMap based on the coordinates you added to your original layer table in the previous step. You will label this new XY layer.

    Note:
    For directions on how to create a new XY layer, open the ArcGIS Desktop Help, select the Index tab, type 'xy', and select the 'adding to maps' heading.

  4. Open the Layer Properties dialog box for the point layer. Select the Labels tab. Place a check mark at Label Features in this layer.
  5. Click the Label Placement button. Open the Placement Properties dialog box. In ArcGIS 8.x, this is done by clicking the Label Placement button, while in 9.0 the button is called Placement Properties. Select the Placement tab.
  6. Select 'Place label at an angle specified by a field'. Then click the Rotation Field button and select a rotation field, such as Angle.

    Note:
    These directions only work if you are rotating labels using the Arithmetic coordinate system.


    Click Ok several times to apply your changes and close the Layer Properties dialog box.
  7. Open the layer table and add two new fields. Call the first field 'OffsetDirection' and make it a text field. Call the second 'Offset' and make it an integer field.
  8. Open the Select by Attributes dialog box. Build a query that is similar to this:
    "Angle" >= 90 AND "Angle" < 270

    Note:
    Actual query syntax will depend on your data type. Use the buttons at the top of the dialog box to help ensure that you build a valid query.

  9. With the table still open, right-click the OffsetDirection field, and select Calculate Values. In the Field Calculator dialog box, enter "Positive" and click Ok. This populates the field for only the selected features.
  10. Click the Options button in the table window and select Switch Selection. Right-click the OffsetDirection field and select Calculate Values. Enter "Negative" and click Ok.
  11. With the table window still open, right-click the Options button, and select Clear Selection.
  12. Populate the Offset field with the number of characters in label field for each label. Click the Offset field, and select Calculate Values. In the Field Calculator enter this expression:

    Len("LABEL_FIELD")

    Where LABEL_FIELD is the field used for the labels.

    Note:
    You may wish to use different criteria to determine the offset distance for your labels, such as shape width if you started with a polygon layer.

  13. Close the table window. Open the Layer Properties dialog box for the layer, select the Symbology tab, and under Categories select the layer symbology option Unique Values, Many Fields.
  14. For the first Value field select OffsetDirection, and for the second Value field select Offset. Click the Add All Values button. Click Apply.
  15. Use these symbol classes to build label classes. Select the Labels tab. Change the Method dropdown list to 'Define class of features and label each class differently'. Click the Get Symbol Classes Button.

    Note:
    If you wish you can discard/change your symbology any time after this point. The only reason for creating symbology classes was to quickly build label classes.

  16. Modify the X offset for the text symbol for each class. To do this:
    a. Select a class from the Class dropdown list.
    b. Click the Symbol button.
    c. Click the Properties button.
    d. Change the X Offset.
  17. If there is a Positive label class, set a positive offset (moves the text label to the right). Conversely, if there is a Negative label class, set a negative offset (to move the label to the left).
  18. Use the value from the Offset field to determine how far to offset the label. Labels that have more characters are longer and need to offset farther. Click OK several times to close all the dialog boxes and view the map. It may take a couple tries to settle on a good X offset for the first label class.

    Note:
    Once you figure out the correct offset for the first class, you can calculate the ratio of num_characters : required offset, and use the same ratio to set the offset for subsequent classes.

  19. Repeat steps 17-19 for each Label Class.
  20. Save your work by saving your map. Also, to use this layer in other maps, right-click on the layer in the Table of Contents and select Save as Layer File. This creates a .lyr file that you can add to other maps.