平均最近邻 (空间统计)

摘要

根据每个要素与其最近邻要素之间的平均距离计算其最近邻指数。

You can access the results of this tool (including the optional report file) from the Results window. If you disable background processing, results will also be written to the Progress dialog box.

详细了解“平均最近邻距离”的工作原理

插图

Average Nearest Neighbor illustration

用法

语法

AverageNearestNeighbor_stats (Input_Feature_Class, Distance_Method, Generate_Report, {Area})
参数说明数据类型
Input_Feature_Class

要对平均最近邻距离进行计算的要素类(通常是点要素类)。

Feature Layer
Distance_Method

指定计算每个要素与邻近要素之间的距离的方式。

  • EUCLIDEAN_DISTANCE两点间的直线距离
  • MANHATTAN_DISTANCE沿垂直轴度量的两点间的距离(城市街区);计算方法是对两点的 x 和 y 坐标的差值(绝对值)求和。
String
Generate_Report
  • NO_REPORT不会创建图形汇总(默认值)。
  • GENERATE_REPORT图形汇总将以 HTML 文件形式创建。
Boolean
Area
(可选)

表示研究区域大小的数值。默认值是包含所有要素(或所有选定要素)的最小外接矩形的面积。单位应与“输出坐标系”的单位一致。

Double

代码示例

平均最近邻 (AverageNearestNeighbor) 示例 1(Python 窗口)

下面的 Python 窗口脚本演示了如何使用平均最近邻 (AverageNearestNeighbor) 工具。

import arcpy
arcpy.env.workspace = r"C:\data"
arcpy.AverageNearestNeighbor_stats("burglaries.shp", "EUCLIDEAN_DISTANCE", "NO_REPORT", "#")
平均最近邻 (AverageNearestNeighbor) 示例 2(独立 Python 脚本)

下面的独立 Python 脚本演示了如何使用平均最近邻 (AverageNearestNeighbor) 工具。

# Analyze crime data to determine if spatial patterns are statistically significant
 
# Import system modules
import arcpy
 
# Local variables...
workspace = "C:/data"
crime_data = "burglaries.shp"
 
try:
    # Set the current workspace (to avoid having to specify the full path to the feature classes each time)
    arcpy.env.workspace = workspace
 
    # Obtain Nearest Neighbor Ratio and z-score
    # Process: Average Nearest Neighbor...
    nn_output = arcpy.AverageNearestNeighbor_stats(crime_data, "EUCLIDEAN_DISTANCE", "NO_REPORT", "#")
    
    # Create list of Average Nearest Neighbor output values by splitting the result object
    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]
    print "The p-value of the nearest neighbor index is: " + nn_values[2]
    print "The expected mean distance is: " + nn_values[3]
    print "The observed mean distance is: " + nn_values[4]
    print "The path of the HTML report: " + nn_values[5]
 
except:
    # If an error occurred when running the tool, print out the error message.
    print arcpy.GetMessages()

环境

输出坐标系

在进行分析之前将要素几何投影到输出坐标系。所有数学计算都基于输出坐标系空间参考

相关主题


7/10/2012