Show Navigation | Hide Navigation
You are here:
Geoprocessing tool reference > Spatial Statistics toolbox > Analyzing Patterns toolset > Tools

Average Nearest Neighbor (Spatial Statistics)

Release 9.2
Last modified January 9, 2009
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Tools"


Related Topics

Calculates a nearest neighbor index based on the average distance from each feature to its nearest neighboring feature.

Learn more about how Average Nearest Neighbor Distance works


Illustration

Average Nearest Neighbor illustration

Usage tips

Command line syntax
An overview of the Command Line window
AverageNearestNeighbor_stats <Input_Feature_Class> <Euclidean Distance | Manhattan Distance> <Display_Output_Graphically> {Area}

Parameter Explanation Data Type
<Input_Feature_Class>

The point feature class for which the average nearest neighbor distance will be calculated.

Feature Layer
<Euclidean Distance | Manhattan Distance>

Specifies how distances are calculated in the nearest neighbor calculation.

  • Euclidean (as the crow flies) — The straight-line distance between two points.
  • Manhattan (city block) — The distance between two points measured along axes at right angles. Calculated by summing the (absolute) differences between point coordinates.

String
<Display_Output_Graphically>

Specifies whether the tool will display the nearest neighbor index graphically.

  • True — The output will be displayed graphically.
  • False — The output will not be displayed graphically.

Boolean
{Area}

The area of the nearest neighbor analysis. The default area value is the area of the minimum enclosing rectangle. The units of this parameter are the input feature class' coordinate system's units squared.

Double
Data types for geoprocessing tool parameters


Command line example

workspace e:\tongass\data
AverageNearestNeighbor harvested.shp 'Euclidean Distance' true #

Scripting syntax
About getting started with writing geoprocessing scripts
AverageNearestNeighbor_stats (Input_Feature_Class, Distance_Method, Display_Output_Graphically, Area)

Parameter Explanation Data Type
Input_Feature_Class (Required)

The point feature class for which the average nearest neighbor distance will be calculated.

Feature Layer
Distance_Method (Required)

Specifies how distances are calculated in the nearest neighbor calculation.

  • Euclidean (as the crow flies) — The straight-line distance between two points.
  • Manhattan (city block) — The distance between two points measured along axes at right angles. Calculated by summing the (absolute) differences between point coordinates.

String
Display_Output_Graphically (Required)

Specifies whether the tool will display the nearest neighbor index graphically.

  • True — The output will be displayed graphically.
  • False — The output will not be displayed graphically.

Boolean
Area (Optional)

The area of the nearest neighbor analysis. The default area value is the area of the minimum enclosing rectangle. The units of this parameter are the input feature class' coordinate system's units squared.

Double

Data types for geoprocessing tool parameters


Script example

# Analyze crime data to determine if spatial patterns are statistically significant

# Import system modules
import arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

# Local variables...
workspace = "C:/project93/data"
crime_data = "burglaries.shp"

try:
    # Set the current workspace (to avoid having to specify the full path to the feature classes each time)
    gp.workspace = workspace

    # Obtain Nearest Neighbor Ratio and Z Score
    # Process: Average Nearest Neighbor...
    nn_output = gp.AverageNearestNeighbor_stats(crime_data, "Euclidean Distance", "false", "#")
    nn_values = nn_output.split(";")
    print "The nearest neighbor index is: " + nn_values[0]
    print "The z score of the nearest neighbor index is: " + nn_values[1]

except:
    # If an error occurred when running the tool, print out the error message.
    print gp.GetMessages()

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.