Generate Near Table (Analysis)

License Level:BasicStandardAdvanced

Summary

Calculates distances and other proximity information between features in one or more feature class or layer. Unlike the Near tool, which modifies the input, Generate Near Table writes results to a new stand-alone table and supports finding more than one near feature.

Learn more about how proximity is calculated by geoprocessing tools

Illustration

Generate Near Table

Usage

Syntax

GenerateNearTable_analysis (in_features, near_features, out_table, {search_radius}, {location}, {angle}, {closest}, {closest_count}, {method})
ParameterExplanationData Type
in_features

The input features that can be point, polyline, polygon, or multipoint type.

Feature Layer
near_features
[near_features,...]

One or more layer of feature class containing near feature candidates. The near features can be of point, polyline, polygon, or multipoint. If multiple layers or feature classes is specified, a field named NEAR_FC is added to the input table and will store the paths of the source feature class containing the nearest feature found. The same feature class or layer may be used as both input and near features.

Feature Layer
out_table

The output table containing the result of the analysis.

Table
search_radius
(Optional)

The radius used to search for near features. If no value is specified, all near features will be candidates. If a distance is entered, but the unit is left blank or set to Unknown, the units of the coordinate system of the input features are used. If the GEODESIC option is used in the Method parameter, a linear unit such as Kilometers or Miles should be used.

Linear unit
location
(Optional)

Specifies whether x- and y-coordinates of the input feature's location and nearest location of the near feature will be written to the FROM_X, FROM_Y, NEAR_X, and NEAR_Y fields.

  • NO_LOCATION Locations will not be written to the output table. This is the default.
  • LOCATION Locations will be written to the output table.
Boolean
angle
(Optional)

Specifies whether the near angle will be calculated and written to a NEAR_ANGLE field in the output table. A near angle measures direction of the line connecting an input feature to its nearest feature at their closest locations. When the PLANAR method is used in the method parameter, the angle is within the range of -180° to 180°, with 0° to the east, 90° to the north, 180° (or -180°) to the west, and -90° to the south. When the GEODESIC method is used, the angle is within the range of -180° to 180°, with 0° to the north, 90° to the east, 180° (or -180°) to the south, and -90° to the west.

  • NO_ANGLENEAR_ANGLE will not be added to the output table. This is the default.
  • ANGLENEAR_ANGLE will be added to the output table.
Boolean
closest
(Optional)

Specifies whether to return only the closest features or multiple features.

  • CLOSESTOnly the closest near feature will be written to the output table. This is the default.
  • ALLMultiple near features will be written to the output table (a limit can be specified in the closest_count parameter).
Boolean
closest_count
(Optional)

Limit the number of near features reported for each input feature. This parameter is ignored if the closest parameter is set to CLOSEST.

Long
method
(Optional)

Determines whether to use a shortest path on a spheroid (geodesic) or a flat earth (planar). It is strongly suggested to use GEODESIC method with data stored in a coordinate system which is not appropriate for distance measurements (for example, Web Mercator and any geographic coordinate system), or any dataset which spans a large geographic area.

  • PLANARUses planar distances between the features. This is the default.
  • GEODESICUses geodesic distances between features. This method takes into account the curvature of the spheroid and correctly deals with data near the dateline and poles.
String

Code Sample

GenerateNearTable example 1 (Python window)

The following demonstrates how to use the GenerateNearTable function in the Python window.

import arcpy

arcpy.env.workspace = "C:/data/input/gnt.gdb"

arcpy.GenerateNearTable_analysis("campsites", ["parks", "trails"], "better_sites")
GenerateNearTable example 2 (stand-alone Python script)

The following Python script demonstrates how to use the GenerateNearTable function in a stand-alone script.

# Name: GenerateNearTable.py
# Description: Finds 3 nearest in the near feature class from the input feature class.


# import system modules
import arcpy

# set workspace environment
arcpy.env.workspace = "C:/data/input/gnt.gdb"

# set required parameters 
in_features = "campsites"
near_features = ["parks", "trails"]
out_table = "near_parks_trails"

# optional parameters
search_radius = '1500 Meters'
location = 'NO_LOCATION'
angle = 'NO_ANGLE'
closest = 'ALL'
closest_count = 3

try:
    # find crime locations within the search radius
    arcpy.GenerateNearTable_analysis(in_features, near_features, out_table, search_radius, 
                                     location, angle, closest, closest_count)
except:
    print arcpy.GetMessages()

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: No
ArcGIS for Desktop Standard: No
ArcGIS for Desktop Advanced: Yes
3/3/2014