Generate Near Table (Analysis)
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.
The output table will have the following fields:
The ObjectID of the input feature.
The ObjectID of the nearest feature.
The distance from the input feature to the near feature. The value of this field is in the linear unit of the input features coordinate system, or Meters when the Method parameter is set to GEODESIC and the input is in a geographic coordinate system.
The catalog path to the feature class that contains the near feature. This field is only added to the output table if multiple Near Features are specified.
An integer value ranking all near features based on their proximity to an individual input feature. The closest feature will get a NEAR_RANK value of 1, the second closest will get a NEAR_RANK value of 2, and so on.
The following fields will be added to the output table if the Location parameter is checked (location parameter set to LOCATION in scripting).
X-coordinate of the location on the input feature which is closest to the near feature.
Y-coordinate of the location on the input feature which is closest to the near feature.
X-coordinate of the location on the near feature which is closest to the input feature.
Y-coordinate of the location on the near feature which is closest to the input feature.
The following field will be added to the output table if the Angle parameter is checked (angle parameter set to ANGLE in scripting).
Angle of the line at the FROM_X and FROM_Y location which connects the input features to the near feature.
When the input and near feature intersect, the following values are written to the output table:
- NEAR_ANGLE and NEAR_DIST will be set to 0.0.
- FROM_X and FROM_Y will be identical to NEAR_X and NEAR_Y and will be a location within the intersection of the two features.
The values in the NEAR_DIST field is in the linear unit of the input features coordinate system. If the input is in a geographic coordinate system and Method parameter is set to GEODESIC, NEAR_DIST units will be meters.
The output table can be joined back to the input features using the IN_FID or to the near features using the NEAR_FID.
If a Search Radius is specified and no near feature is found, no record will be output.
If no Search Radius is specified, all near features will be considered as candidates.
If no Search Radius is specified and Find only closest features is unchecked (closest set to ALL in scripting), and Maximum number of closest is left to default (0 or empty), the output table will contain distance calculations between all input features and all near features. This kind of process can take quite a long time and can create a large output table. For example, if you have 1,000 input features and 1,000 near features, the output table will contain 1,000,000 records.
The same feature class or layer may be used as both input and near features. In this situation, the input feature being evaluated is excluded from the near features candidates to avoid all features being closest to themselves.
When using the PLANAR option for the Method parameter, the input features should be in a projection that is appropriate for distance measurement, such as an equidistant projections.
The input features that can be point, polyline, polygon, or multipoint type.
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.
The output table containing the result of the analysis.
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.
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.
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.
Specifies whether to return only the closest features or multiple features.
Limit the number of near features reported for each input feature. This parameter is ignored if the closest parameter is set to CLOSEST.
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.
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")
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()