Generate Near Table (Analysis)

Summary

Determines the distances from each feature in the input features to one or more nearby features in the near features, within the search radius. The results are recorded in the output table.

Illustration

Generate Near Table Illustration

Usage

Syntax

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

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

Feature Layer
near_features
[near_features,...]

Value used to find the nearest features from input features. There can be one or more entries of near features; each entry can be of point, polyline, polygon, or multipoint type. When multiple entries of near features are specified, a new field, NEAR_FC, is added to the input table to store the paths of the source feature class that contains the nearest features.

Feature Layer
out_table

The output table that will contain the proximity information—such as IN_FID, NEAR_FID, and NEAR_DIST—and other attributes—such as location (NEAR_X, NEAR_Y) and angle (NEAR_ANGLE)—of the near feature and the NEAR_FC, if necessary.

Table
search_radius
(Optional)

Specifies the radius used to search for candidate near features. The near features within this radius are considered for calculating the nearest feature. If no value is specified, that is, the default (empty) radius is used, all near features are considered for calculation. The unit of the search radius defaults to the units of the coordinate system of the input features. The units can be changed to any other unit. However, this has no impact on the units of NEAR_DIST which is based on the units of the coordinate system of the input features.

Linear unit
location
(Optional)

Specifies whether x- and y-coordinates of the nearest location of the near feature will be written to new fields NEAR_X and NEAR_Y, respectively.

  • NO_LOCATIONSpecifies that the x- and y-coordinates of the nearest location will not be written. This is the default.
  • LOCATIONSpecifies that the x- and y-coordinates of the nearest location will be written to NEAR_X and NEAR_Y fields.
Boolean
angle
(Optional)

Specifies whether the near angle values in decimal degrees will be calculated and written to a new field, NEAR_ANGLE. A near angle measures from the x-axis (horizontal axis) to the direction of the line connecting an input feature to its nearest feature at their closest locations, and it is within the range of 0 to 180 or 0 to -180 decimal degrees - 0 to the east, 90 to the north, 180 (-180°) to the west, and -90 to the south.

  • NO_ANGLESpecifies that the near angle values will not be written. This is the default.
  • ANGLESpecifies that the near angle values will be written to the NEAR_ANGLE field.
Boolean
closest
(Optional)

Determines whether to locate and return only the closest features or all the features within the search radius.

  • CLOSESTLocate and return only the closest features from the near features to the input features within the search radius. This is the default.
  • ALLLocate and return all features from the near features to the input features within the search radius.
Boolean
closest_count
(Optional)

Find only the specified number of closest features. This parameter will not be used if the Find only closest feature option is checked.

Long

Code Sample

GenerateNearTable example 1 (Python window)

The following snippet 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
from arcpy import env

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

# set required parameters 
inFeatures = "campsites"
nearFeatures = ["parks", "trails"]
outTable = "near_parks_trails"

# optional parameters
searchRadius = '1500 Meters'
location = 'NO_LOCATION'
angle = 'NO_ANGLE'
closest = 'ALL'
closestCount = 3

# find crime locations within the search radius
arcpy.GenerateNearTable_analysis(inFeatures, nearFeatures, outTable, searchRadius, location, angle, closest, closestCount)

Environments

Related Topics

Licensing Information

ArcView: No
ArcEditor: No
ArcInfo: Yes

4/4/2012