HOW TO

Calculate the direction a polygon faces in relation to another feature in ArcGIS Pro

Last Published: June 13, 2024

Summary

Determining the direction where a polygon faces in relation to another feature is important for navigation and geographical orientation, such as the direction where a building faces in relation to a road helps identify the building's orientation on a map.

This article highlights the workflow on how to calculate the direction where a polygon faces in relation to another feature in ArcGIS Pro.

Procedure

  1. Use the Near tool to identify the angle of the nearest feature to the polygon.
    1. In ArcGIS Pro, on the ribbon, click Analysis > Tools.
    2. In the Geoprocessing pane, search for and click the Near tool.
    3. In the Near pane, on the Parameters tab, select the polygon layer for Input Features. This example uses ‘house’.
    4. Select the second feature for Near Features. This example uses the line feature, ‘roads’.
    5. Check the Angle check box.
    6. For Distance Unit, select an appropriate unit of measurement.
    7. Click Run.
Parameters in the Near tool
  1. Open the attribute table of the polygon feature layer. Refer to ArcGIS Pro: Add and open a stand-alone or attribute table from a map or scene 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 field is named ‘Proximity’.
A new text field is created in the attribute table
  1. Run the Calculate Field tool on the newly created field.
    1. Select a feature layer for Input Table. This example uses ‘house’.
    2. For Field Name (Existing or New), select the new field created in Step 3. In this example, ‘Proximity’ field is selected.
    3. Select Python for Expression Type.
    4. In the Expression parameter, insert the following script.
angle (!NEAR_ANGLE!)
  1. For Code Block, insert the following script and click the Verify button.
def angle (angle):
 if  90 > angle > 0 :
  return " North East"
 if 0 > angle > -90:
  return "South East"
 if  90 < angle < 180 :
  return " North West"
 if -90 > angle > -180:
  return "South West"
 if  angle == 0:
  return "East"
 if  angle == 90:
  return "North"
 if  angle == -90:
  return "South"
 if  angle == 180:
  return "West"
 if  angle == -180:
  return "West"
  1. Click Apply > OK.

The direction of the polygon relative to the line feature is populated in the 'Proximity' column.

The attribute table is populated

Article ID: 000031041

Software:
  • ArcGIS Pro 3 1
  • ArcGIS Pro 3 3
  • ArcGIS Pro 3 2

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