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. Results are accessible from the Results window.
The Average Nearest Neighbor tool is contained in the Spatial Statistics Tools tool box.
Usage tips:
- The Average Nearest Neighbor tool returns five values: Observed Mean Distance, Expected Mean Distance, Nearest Neighbor Index, z-score, and p-value. These values are accessible from the and are also passed as derived output values for potential use in models or scripts. Optionally, this tool will create an HTML file with a graphical summary of results. Double-clicking on the HTML entry in the Results window will open the HTML file in the default Internet browser. Right-clicking on the in the Results window and selectingwill display the results in a. If you execute this tool in the , output values will also be displayed in the.
- The results are measures of statistical significance which tell you whether or not to reject the null hypothesis. For the Average Nearest Neighbor statistic, the null hypothsis states that features are randomly distributed.
- The Nearest Neighbor Index is expressed as the ratio of the Observed Mean Distance to the Expected Mean 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 method is very sensitive to the Area value (small changes in the Area parameter value can result in considerable changes in the results). Consequently, the Average Nearest Neighbor tool is most effective for comparing different features in a fixed study area. Use the on the study area polygon as one way to get an Area value for the Area parameter. The picture below is a classic example of how identical feature distributions can be dispersed or clustered depending on the study area specified.
- If an Area parameter value is not specified, then the area of the minimum enclosing rectangle around the input features is used. Unlike the extent, a minimum enclosing rectangle will not necessarily align with the x- and y-axes.
- There are special cases of input features that would result in invalid (zero-area) minimum enclosing rectangles. In these cases, a small value derived from the input feature XY tolerance will be used to create the minimum enclosing rectangle. For example, if all features are coincident (i.e., all have the exact same X and Y coordinates), the area for a very small square polygon around the single location will be used in calculations. Another example would be if all features align perfectly (e.g., 3 points in a straight line); in this case the area of a rectangle polygon with a very small width around the features will be used in computations. 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 most appropriate for event, incident, or other fixed-point feature data. For line and polygon features, the true geometric centroid for each feature is used in 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.
- Calculations based on either Euclidean or Manhattan distance require to accurately measure distances.
- Map layers can be used to define the Input Feature Class. When using a layer with a selection, only the selected features are included in the analysis.
- When 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. See also .
Constructor Summary |
AverageNearestNeighbor()
Creates the Average Nearest Neighbor tool with defaults. |
AverageNearestNeighbor(java.lang.Object inputFeatureClass,
java.lang.String distanceMethod)
Creates the Average Nearest Neighbor tool with the required parameters. |
Method Summary |
double |
getArea()
Returns the Area parameter of this tool . |
java.lang.String |
getDistanceMethod()
Returns the Distance Method parameter of this tool . |
java.lang.String |
getGenerateReport()
Returns the Generate Report parameter of this tool . |
java.lang.Object |
getHTMLReportFile()
Returns the HTML Report File parameter of this tool (Read only). |
java.lang.Object |
getInputFeatureClass()
Returns the Input Feature Class parameter of this tool . |
double |
getNNExpected()
Returns the NNExpected parameter of this tool (Read only). |
double |
getNNObserved()
Returns the NNObserved parameter of this tool (Read only). |
double |
getNNRatio()
Returns the NNRatio parameter of this tool (Read only). |
double |
getNNZScore()
Returns the NNZScore parameter of this tool (Read only). |
double |
getPValue()
Returns the PValue parameter of this tool (Read only). |
java.lang.String |
getToolboxAlias()
Returns the alias of the tool box containing this tool. |
java.lang.String |
getToolboxName()
Returns the name of the tool box containing this tool. |
java.lang.String |
getToolName()
Returns the name of this tool. |
void |
setArea(double area)
Sets the Area parameter of this tool . |
void |
setDistanceMethod(java.lang.String distanceMethod)
Sets the Distance Method parameter of this tool . |
void |
setGenerateReport(java.lang.String generateReport)
Sets the Generate Report parameter of this tool . |
void |
setInputFeatureClass(java.lang.Object inputFeatureClass)
Sets the Input Feature Class parameter of this tool . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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(java.lang.Object inputFeatureClass,
java.lang.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
- the feature class, typically a point feature class, for which the average nearest neighbor distance will be calculated.distanceMethod
- specifies how distances are calculated from each feature to neighboring features.
getInputFeatureClass
public java.lang.Object getInputFeatureClass()
- Returns the Input Feature Class parameter of this tool .
This parameter is 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(java.lang.Object inputFeatureClass)
- Sets the Input Feature Class parameter of this tool .
This parameter is 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
- the feature class, typically a point feature class, for which the average nearest neighbor distance will be calculated.
getDistanceMethod
public java.lang.String getDistanceMethod()
- Returns the Distance Method parameter of this tool .
This parameter is specifies how distances are calculated from each feature to neighboring features.
This is a required parameter.
- Returns:
- the Distance Method
setDistanceMethod
public void setDistanceMethod(java.lang.String distanceMethod)
- Sets the Distance Method parameter of this tool .
This parameter is specifies how distances are calculated from each feature to neighboring features.
This is a required parameter.
- Parameters:
distanceMethod
- specifies how distances are calculated from each feature to neighboring features.
getGenerateReport
public java.lang.String getGenerateReport()
- Returns the Generate Report parameter of this tool .
This is an optional parameter.
- Returns:
- the Generate Report
setGenerateReport
public void setGenerateReport(java.lang.String generateReport)
- Sets the Generate Report parameter of this tool .
This is an optional parameter.
- Parameters:
generateReport
- null
getArea
public double getArea()
- Returns the Area parameter of this tool .
This parameter is 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 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
- 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
getNNExpected
public double getNNExpected()
- Returns the NNExpected parameter of this tool (Read only).
This is an derived parameter.
- Returns:
- the NNExpected
getNNObserved
public double getNNObserved()
- Returns the NNObserved parameter of this tool (Read only).
This is an derived parameter.
- Returns:
- the NNObserved
getHTMLReportFile
public java.lang.Object getHTMLReportFile()
- Returns the HTML Report File parameter of this tool (Read only).
This is an derived parameter.
- Returns:
- the HTML Report File
getToolName
public java.lang.String getToolName()
- Returns the name of this tool.
- Returns:
- the tool name
getToolboxName
public java.lang.String getToolboxName()
- Returns the name of the tool box containing this tool.
- Returns:
- the tool box name
getToolboxAlias
public java.lang.String getToolboxAlias()
- Returns the alias of the tool box containing this tool.
- Returns:
- the tool box alias