ArcGIS Desktop

  • 文档
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

汇总统计数据

  • 摘要
  • 用法
  • 语法
  • 代码示例
  • 环境
  • 许可信息

摘要

为表中字段计算汇总统计数据。

用法

  • 输出表将由包含统计运算结果的字段组成。

  • 使用此工具可执行以下统计运算:总和、平均值、最大值、最小值、范围、标准差、计数、第一个和最后一个。中值运算不可用。

  • 将使用以下命名约定为每种统计类型创建字段:SUM_<field>、MAX_<field>、MIN_<field>、RANGE_<field>、STD_<field>、FIRST_<field>、LAST_<field> 和 COUNT_<field>(其中 <field> 是计算统计数据的输入字段的名称)。当输出表是 dBASE 表时,字段名称会被截断为 10 个字符。

  • 如果已指定案例分组字段,则单独为每个唯一属性值计算统计数据。如果未指定案例分组字段,则输出表中将仅包含一条记录。如果已指定一个案例分组字段,则每个案例分组字段值均有一条对应的记录。

  • 空值将被排除在所有统计计算之外。例如,10、5 和空值的 AVERAGE 为 7.5 ((10+5)/2)。COUNT 工具可返回统计计算中所包括值的数目,如本例中为 2。

  • 统计字段参数添加字段按钮仅可以在“模型构建器”中使用。在模型构建器中,如果先前的工具尚未运行或其派生数据不存在,则可能不会使用字段名称来填充统计字段参数。添加字段按钮可用于添加所需字段,以完成“汇总统计数据”对话框并继续构建模型。

  • 使用图层时,仅使用当前所选要素计算统计数据。

语法

Statistics_analysis (in_table, out_table, statistics_fields, {case_field})
参数说明数据类型
in_table

包含用于计算统计数据的字段的输入表。输入可以是 INFO 表、dBASE 表、OLE DB 表、VPF 表或要素类。

Table View; Raster Layer
out_table

将存储计算的统计数据的输出 dBASE 或地理数据库表。

Table
statistics_fields
[[field, statistics_type],...]

包含用于计算指定统计数据的属性值的数字字段。可以指定多项统计数据和字段组合。空值将被排除在所有统计计算之外。

“添加字段”按钮(只能在模型构建器中使用)可用于添加所需字段,以完成对话框并继续构建模型。

可用的统计类型有:

  • SUM - 添加指定字段的合计值。
  • MEAN - 计算指定字段的平均值。
  • MIN - 查找指定字段所有记录的最小值。
  • MAX - 查找指定字段所有记录的最大值。
  • RANGE - 查找指定字段的值范围 (MAX - MIN)。
  • STD - 查找指定字段中的值的标准差。
  • COUNT - 查找统计计算中包括的值的数目。计数范围包括除空值外的每个值。要确定字段中的空值数,请在相应字段上使用 COUNT 统计,然后在另一个不包含空值的字段上使用 COUNT 统计(例如 OID,如果存在的话),然后将这两个值相减。
  • FIRST - 查找“输入表”中的第一条记录,并使用该记录的指定字段值。
  • LAST - 查找“输入表”中最后一条记录,并使用该记录的指定字段值。
Value Table
case_field
[case_field,...]
(可选)

“输入表”中用于为每个唯一属性值(如果指定多个字段,则为属性值组合)单独计算的统计数据的字段。

Field

代码示例

统计数据示例(Python 窗口)

以下 Python 窗口脚本演示了如何在即时模式下使用统计数据工具。

import arcpy
from arcpy import env
env.workspace = "C:/data/Habitat_Analysis.gdb"
arcpy.Statistics_analysis("futrds", "C:/output/output.gdb/stats", [["Shape_Length", "SUM"]], "NM")
统计数据示例 2(独立脚本)

以下独立脚本汇总了主要道路 150 英尺范围内的植被区域。

# Name: Statistics_Example2.py
# Description: Summarize the vegetation by area within 150 feet of major roads
 
# Import system modules
import arcpy
from arcpy import env
 
# Set environment settings
env.workspace = "C:/data"
 
# Set local variables
inRoads = "majorrds.shp"
outBuffer = "C:/output/output.gdb/buffer_out"
bufferDistance = "250 feet"
inVegetation = "Habitat_Analysis.gdb/vegtype"
outClip = "C:/output/output.gdb/clip_out"
joinField = "HOLLAND95"
joinTable = "c:/data/vegtable.dbf"
joinedField = "HABITAT"
outStatsTable = "C:/output/output.gdb/stats_out"
statsFields = [["Shape_Area", "SUM"]]
 
# Execute Buffer to get a buffer of major roads
arcpy.Buffer_analysis(inRoads, outBuffer, bufferDistance, dissolve_option = "ALL")
 
# Execute Clip using the buffer output to get a clipped feature class
#  of vegetation
arcpy.Clip_analysis(inVegetation, outBuffer, outClip)
 
# Execute JoinField to add the vegetation type
arcpy.JoinField_management(outClip, joinField, joinTable, joinField, joinedField)
 
# Execute Statistics to get the area of each vegetation type within
#  the clipped buffer.
arcpy.Statistics_analysis(outClip, outStatsTable, statsFields, joinedField)
Statistics 示例 3(独立脚本)

以下独立脚本循环遍历数据集的属性字段并构造统计字段参数,从而计算各个数值字段的 SUM 统计量。

# Name: Statistics_Example3_SUM_All.py
# Description: Script that runs the Summary Statistic tool to calculate the
#   Sum statistic for every numeric field based on a unique case field
# Import system modules
import arcpy
# Set environment settings
env.workspace = "C:/data/f.gdb"
# Set local variables
intable = "intable"
outtable = "sumstats"
casefield = "Name"
stats = []
# Loop through all fields in the Input Table
for field in arcpy.ListFields(intable):
    # Just find the fields that have a numeric type
    if field.type in ("Double", "Integer", "Single", "SmallInteger"):
        # Add the field name and Sum statistic type
        #    to the list of fields to summarize
        stats.append([field.name, "Sum"])
# Correct formatting of stats [["Field1", "Sum"], ["Field2", "Sum"], ...]
# Run the Summary Statistics tool with the stats list
arcpy.Statistics_analysis(intable, outtable, stats, casefield)

环境

  • 输出配置关键字
  • 当前工作空间
  • 临时工作空间

许可信息

  • ArcGIS Desktop Basic: 是
  • ArcGIS Desktop Standard: 是
  • ArcGIS Desktop Advanced: 是

相关主题

  • 统计分析工具集概述

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2018 Esri. | 隐私政策 | 法律声明