HOW TO

Determine the compass direction of line features in ArcGIS Pro

Last Published: September 3, 2023

Summary

In ArcGIS Pro, directions of line features can be determined by the compass direction. This is important to show the cardinal and ordinal directions used for navigation and geographic orientation.

This article describes the workflow to determine the compass direction of line features in ArcGIS Pro.

Procedure

  1. Use the Linear Directional Mean tool output to obtain the compass angle of the line features.
    1. On the Analysis tab, click Tools to open the Geoprocessing pane.
    2. In the Geoprocessing pane, search for and click the Linear Directional Mean tool.
    3. In the Linear Directional Mean pane, on the Parameters tab, select the polygon feature layer from the Input Feature Class drop-down list. In this example, 'Line' is selected.
    4. Specify a name for Output Feature Class.
    5. Select a field for Case Field.
Note: 
The Case Field is used to group features for separate linear directional mean computations. When a Case Field is specified, the input line features are first grouped according to case field values, then an output line feature is created for each group. The case field can be of integer, date, or string type. Records with NULL values for the Case Field are excluded from analysis.
  1. Click Run.
  1. Open the attribute table of the feature class created in Step 1. Refer to ArcGIS Pro: Open a table from a catalog view or the Catalog pane for instructions.
  2. Add a new text field to the attribute table. Refer to ArcGIS Pro: Add Field (Data Management) for more information. In this example, the text field is named as 'Direction'.
A new Text field is created
  1. Use the Calculate Field tool to create a Python function to convert the angle values to text direction.
    1. For Input Table, select the attribute table of the feature class created in Step 1.
    2. Select Direction for Field Name.
    3. For Expression Type, select Python 3.
    4. Type the following script in the Expression code box.
direction(!CompassA!)
  1. Type the following script in the Code Block.
Note: 
The following script defines the direction based on the north of the map. The line continues to take into account the north of the map even if it is tilted.
def direction(var):
   if var < 22.5:
      return "North"
   if var >= 22.5 and var < 67.5:
      return "Northeast"
   if var >= 67.5 and var < 112.5:
      return "East"
   if var >= 112.5 and var < 157.5:
      return "Southeast"
   if var >= 157.5 and var < 202.5:
      return "South"
   if var >= 202.5 and var < 247.5:
      return "Southwest"
   if var >= 247.5 and var < 292.5:
      return "West"
   if var >= 292.5 and var < 337.5:
      return "Northwest"
   if var >= 337.5:
      return "North"
  1. Click OK.

The direction of the line features are displayed in the attribute table as shown in the image below.

The line directions are displayed in the attribute table

Article ID: 000030990

Software:
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 0
  • ArcGIS Pro 2 9x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options