English

How To: Calculate the intercardinal direction from one point to a set of points

Summary

The instructions provided describe a workflow that is intended for situations where a set of points surrounds a main point and the intercardinal (ordinal) direction (NW, NE, SW, SE) must be added as a field to the table.

This is useful when determining the quadrant in which a point, or group of points, lies with respect to a central point.

Procedure

This workflow requires the use of the Generate Near Table tool and Python code in the Field Calculator. This workflow assumes there are two separate point feature classes.

Note:
The Generate Near Table tool requires an Advanced license.
  1. Open the Generate Near Table tool. In ArcToolbox, click Analysis Tools > Proximity > Generate Near Table.
    1. Under Input Features, select the point feature from which the direction is located.
    2. Under Near Features, select the points that surround the input point feature.
    3. Set the desired Search Radius.
    4. Check the Location and Angle boxes.
    5. Uncheck Find only closest feature.
    6. Under Method, select PLANAR (optional).
      Note:
      This workflow is intended for use with the Planar option. The Geodesic method produces different results that might not be compatible with this workflow. The Generate Near Table and Near tools were completely rewritten at ArcGIS version 10.2.1 to be dramatically faster and have an optional Method parameter that determines how distances are computed. 
      
      When Method is set to GEODESIC, distances are calculated across the Earth's surface. This is most accurate when the distance between features is large and you want to minimize the distortion inherent in all projected coordinate systems, particularly in projections like Web Mercator. 
      
      When set to PLANAR, Euclidean distances are calculated using the coordinates of the features and is appropriate for projections that minimize distance distortion or when the distance between features is small. Please see What's new in ArcGIS 10.2.1 for more information.
    7. Click OK to run the tool. The tool outputs a table.
  2. Open the table by right-clicking the table in the Table of Contents and selecting Open.
    1. Add a new field to the table.

      [O-Image]
       
    2. Name the field Direction, and under Type, select Text, and click OK.

      [O-Image]
       
  3. Right-click the Direction field, and click Field Calculator.
  4. Under Parser, select Python and check the Show Codeblock checkbox.

    [O-Image]
     
  5. Add the following code to the Pre-Logic Script Code block:
    def Direction(angle):
      if (angle >= 0 and angle <= 90):
        return "NE"
      if (angle >= 90):
        return "NW"
      if (angle >= -90):
        return "SE"
      if (angle <= -90):
        return "SW"
  6. In the second text box, add the following code:
    Direction(!NEAR_ANGLE!)
  7. Click OK and the result displays the cardinal directions.

    [O-Image]

Related Information