平均中心 (空间统计)
插图
![]() |
用法
-
平均中心是一个根据输入要素质心的平均 x 和 y 值构造的点。
-
将投影数据与此工具结合使用可精确测量距离。
-
平均中心点要素的 x 值和 y 值是输出要素类中的属性。这些值存储在 XCOORD 和 YCOORD 字段中。
-
案例分组字段用于将要素进行分组以独立计算平均中心。当指定了“案例分组字段”时,会首先根据案例分组字段值对输入要素进行分组,然后计算每个组的平均中心。案例分组字段可以为整型、日期型或字符串型。
尺寸字段是输入要素类中的任意数字字段。“平均中心”工具将计算该字段中所有值的平均值,并将结果包括在输出要素类中。
-
对于线和面要素,会在距离计算中使用要素质心。对于多点、折线 (polyline) 或由多部分组成的面,使用所有要素部分的加权平均中心来计算质心。点要素的加权项是 1,线要素的加权项是长度,而面要素的加权项是面积。
-
地图图层可用于定义输入要素类。在使用带有选择内容的图层时,分析只会包括所选的要素。
![警告 警告](rsrc/caution.png)
在使用 shapefile 时,请注意 shapefile 无法存储空值。根据非 shapefile 输入创建 shapefile 的工具或其他过程可能会将空值存储(或解析)为零。这会产生意外的结果。另请参阅 shapefile 输出的地理处理注意事项。
语法
参数 | 说明 | 数据类型 |
Input_Feature_Class |
将对其计算平均中心的要素类。 | Feature Layer |
Output_Feature_Class |
将包含用于表示输入要素类的平均中心的要素的点要素类。 | Feature Class |
Weight_Field (可选) |
用于创建加权平均中心的数字字段。 | Field |
Case_Field (可选) |
用于对要素进行分组以独立计算平均中心的字段。案例分组字段可以为整型、日期型或字符串型。 | Field |
Dimension_Field (可选) |
此数字字段包含一些计算平均值时所根据的属性值。 | Field |
代码示例
以下 Python 窗口脚本演示了如何使用 MeanCenter 工具。
import arcpy arcpy.env.workspace = r"C:\data" arcpy.MeanCenter_stats("coffee_shops.shp", "coffee_MEANCENTER.shp", "NUM_EMP", "#", "#")
以下独立 Python 脚本演示了如何使用 MeanCenter 工具。
# Measure geographic distribution characteristics of coffee house locations weighted by the number of employees # Import system modules import arcpy # Local variables... workspace = "C:/data" input_FC = "coffee_shops.shp" CF_output = "coffee_CENTRALFEATURE.shp" MEAN_output = "coffee_MEANCENTER.shp" MED_output = "coffee_MEDIANCENTER.shp" weight_field = "NUM_EMP" try: # Set the workspace to avoid having to type out full path names arcpy.env.workspace = workspace # Process: Central Feature... arcpy.CentralFeature_stats(input_FC, CF_output, "Euclidean Distance", weight_field, "#", "#") # Process: Mean Center... arcpy.MeanCenter_stats(input_FC, MEAN_output, weight_field, "#", "#") # Process: Median Center... arcpy.MedianCenter_stats(input_FC, MED_output, weight_field, "#", "#") except: # If an error occurred when running the tool, print out the error message. print arcpy.GetMessages()
环境
- 输出坐标系
在进行分析之前将要素几何投影到输出坐标系。所有数学计算都基于输出坐标系空间参考。