com.esri.arcgis.geoprocessing.tools.spatialstatisticstools
Class AverageNearestNeighbor
java.lang.Object
com.esri.arcgis.geoprocessing.AbstractGPTool
com.esri.arcgis.geoprocessing.tools.spatialstatisticstools.AverageNearestNeighbor
- All Implemented Interfaces:
- GPTool
public class AverageNearestNeighbor
- extends AbstractGPTool
Calculates a nearest neighbor index based on the average distance from each feature to its nearest neighboring feature.
The Average Nearest Neighbor tool is contained in the Spatial Statistics Tools tool box.
Learn more about how Average Nearest Neighbor Distance works
Software restrictions: none
Illustration:
Usage tips:
- This tool honors the environment output coordinate system; . Feature geometry; is projected to the output coordinate system prior to analysis, so the units associated with values entered for the Area parameter should match those specified in the output coordinate system. All mathematical computations are based on the output coordinate system spatial reference;
- Calculations based on either Euclidean or Manhattan distance require projected data; to accurately measure distances.
- The nearest neighbor index and associated Z score and p-value are written to the command window and passed as derived output.
- The Z score and p-value are measures of statistical significance which tell you whether or not to reject the null hypothesis. For Average Nearest Neighbor the null hypothsis states that features are randomly distributed.
- The nearest neighbor index is expressed as the ratio of the observed distance divided by the expected distance. The expected distance is the average distance between neighbors in a hypothetical random distribution. If the index is less than 1, the pattern exhibits clustering; if the index is greater than 1, the trend is toward dispersion or competition.
- The average nearest neighbor tool is most effective for comparing different features in a fixed study area. Use the Calculate Area tool; on the Study Area polygon to get an Area value for the area parameter.
- If an Area value is not specified, then the area of the minimum enclosing rectangle around the features is used. Unlike the extent; , a minimum enclosing rectangle will not necessarily align with the x- and y-axes.
- The average nearest neighbor function is very sensitive to the Area value (small changes in the area can result in considerable changes in the results).
- The extent (and minimum enclosing rectangle) for a feature class containing only coincident points (all with the exact same X and Y coordinates) is zero. In this case, even though the points are highly clustered at a single location, the expected distribution for those points in a space with zero area is to have all points coincident. Because the observed and expected distributions are equivalent, the resultant Z score will be 0.0 and the resultant p-value will be 1.0, to indicate that spatial clustering is not statistically significant. It is always best to supply an AREA value when using the Average Nearest Neighbor tool.
- Although this tool will work with polygon or line data, it is really only appropriate for event, incident, or other fixed-point feature data. For line and polygon features, feature true geometric centroids are used in the computations. For multipoint, polyline or polygons with multiple parts, the centroid is computed using the weighted mean center of all feature parts. The weighting for point features is 1, for line features is length, and for polygon features is area.
- Whenever using shapefiles keep in mind that they cannot store null values. Tools or other procedures that create shapefiles from non-shapefile inputs may store or interpret null values as zero. This can lead to unexpected results.
- The "Display Output Graphically" parameter will only work on the Windows operating system. When set to true it will display the results of the tool graphically.
- When output is shown graphically, a separate graphics dialog box will be displayed. If you use the tool in a script, set the Display_Output_Graphically parameter to "false", otherwise your script will not complete until you click"Close" on the popup graphic.
- Current map layers may be used to define the input feature class. When using layers, only the currently selected features are included in the analysis.
- Learn more about working with layers and table views;
AverageNearestNeighbor
public AverageNearestNeighbor()
- Creates the Average Nearest Neighbor tool with defaults.
Initializes the array of tool parameters with the default values specified when the tool was created.
AverageNearestNeighbor
public AverageNearestNeighbor(Object inputFeatureClass,
String distanceMethod)
- Creates the Average Nearest Neighbor tool with the required parameters.
Initializes the array of tool parameters with the values as specified for the required parameters and with the default values for the other parameters.
- Parameters:
inputFeatureClass - Feature Layer, the feature class, typically a point feature class, for which the average nearest neighbor distance will be calculated.distanceMethod - String, specifies how distances are calculated from each feature to its nearest neighboring feature.
getInputFeatureClass
public Object getInputFeatureClass()
- Returns the Input Feature Class parameter of this tool .
This parameter is Feature Layer, the feature class, typically a point feature class, for which the average nearest neighbor distance will be calculated.
This is a required parameter.
- Returns:
- the Input Feature Class
setInputFeatureClass
public void setInputFeatureClass(Object inputFeatureClass)
- Sets the Input Feature Class parameter of this tool .
This parameter is Feature Layer, the feature class, typically a point feature class, for which the average nearest neighbor distance will be calculated.
This is a required parameter.
- Parameters:
inputFeatureClass - Feature Layer, the feature class, typically a point feature class, for which the average nearest neighbor distance will be calculated.
getDistanceMethod
public String getDistanceMethod()
- Returns the Distance Method parameter of this tool .
This parameter is String, specifies how distances are calculated from each feature to its nearest neighboring feature.
This is a required parameter.
- Returns:
- the Distance Method
setDistanceMethod
public void setDistanceMethod(String distanceMethod)
- Sets the Distance Method parameter of this tool .
This parameter is String, specifies how distances are calculated from each feature to its nearest neighboring feature.
This is a required parameter.
- Parameters:
distanceMethod - String, specifies how distances are calculated from each feature to its nearest neighboring feature.
getDisplayOutputGraphically
public String getDisplayOutputGraphically()
- Returns the Display Output Graphically parameter of this tool .
This parameter is String, specifies whether the tool will display the nearest neighbor index graphically.
This is an optional parameter.
- Returns:
- the Display Output Graphically
setDisplayOutputGraphically
public void setDisplayOutputGraphically(String displayOutputGraphically)
- Sets the Display Output Graphically parameter of this tool .
This parameter is String, specifies whether the tool will display the nearest neighbor index graphically.
This is an optional parameter.
- Parameters:
displayOutputGraphically - String, specifies whether the tool will display the nearest neighbor index graphically.
getArea
public double getArea()
- Returns the Area parameter of this tool .
This parameter is Double, a numeric value representing the study area size. The default value is the area of the minimum enclosing rectangle that would encompass all features (or all selected features). Units should match those for the Output Coordinate System.
This is an optional parameter.
- Returns:
- the Area
setArea
public void setArea(double area)
- Sets the Area parameter of this tool .
This parameter is Double, a numeric value representing the study area size. The default value is the area of the minimum enclosing rectangle that would encompass all features (or all selected features). Units should match those for the Output Coordinate System.
This is an optional parameter.
- Parameters:
area - Double, a numeric value representing the study area size. The default value is the area of the minimum enclosing rectangle that would encompass all features (or all selected features). Units should match those for the Output Coordinate System.
getNNRatio
public double getNNRatio()
- Returns the NNRatio parameter of this tool (Read only).
This is an derived parameter.
- Returns:
- the NNRatio
getNNZScore
public double getNNZScore()
- Returns the NNZScore parameter of this tool (Read only).
This is an derived parameter.
- Returns:
- the NNZScore
getPValue
public double getPValue()
- Returns the PValue parameter of this tool (Read only).
This is an derived parameter.
- Returns:
- the PValue
getToolName
public String getToolName()
- Returns the name of this tool.
- Returns:
- the tool name
getToolboxName
public String getToolboxName()
- Returns the name of the tool box containing this tool.
- Returns:
- the tool box name
getToolboxAlias
public String getToolboxAlias()
- Returns the alias of the tool box containing this tool.
- Returns:
- the tool box alias