点统计 (Spatial Analyst)

许可等级:BasicStandardAdvanced

摘要

对每个输出像元周围的邻域中的点计算统计数据。

了解有关“点统计”工作原理的详细信息

用法

语法

PointStatistics (in_point_features, field, {cell_size}, {neighborhood}, {statistics_type})
参数说明数据类型
in_point_features

要在每个输出像元周围的邻域中计算统计数据的输入点要素类。

输入可以是点或多点要素类。

Feature Layer
field

字段可以是输入点要素的任意数值型字段。

如果输入要素包含 z,则它可以是 Shape 字段。

Field
cell_size
(可选)

输出栅格数据集的像元大小。

如果专门进行设置,则是环境中的值。如果环境中未设置,则该值为输出空间参考中输入要素数据集范围的宽度或高度中的较小值除以 250。

Analysis Cell Size
neighborhood
(可选)

邻域类表示用于计算统计数据的各输入点周围区域的形状。

不同类型的可用邻域包括 NbrAnnulusNbrCircleNbrRectangleNbrWedge

以下为邻域的形式:

  • NbrAnnulus({innerRadius}, {outerRadius}, {units})
  • NbrCircle({radius}, {units}
  • NbrRectangle({width}, {height}, {units})
  • NbrWedge({radius}, {startAngle}, {endAngle}, {units})

默认邻域为宽和高为 3 个像元的正方形 NbrRectangle

Neighborhood
statistics_type
(可选)

要计算的统计数据类型。

对每个输出栅格像元的邻域中的点输入的指定字段值执行计算。

  • MEAN 计算每个邻域中的字段值的平均值。
  • MAJORITY 确定每个邻域中出现频率最高的字段值。如果出现平局,使用较低的值。
  • MAXIMUM 确定每个邻域中的最大字段值。
  • MEDIAN 确定每个邻域中的中间字段值。如果邻域中点的数量为偶数,结果将为两个中间值中较低的一个。
  • MINIMUM 确定每个邻域中的最小字段值。
  • MINORITY 确定每个邻域中出现频率最低的字段值。如果出现平局,使用较低的值。
  • RANGE 计算每个邻域中的字段值的范围(最大值与最小值之差)。
  • STD 计算每个邻域中的字段值的标准差。
  • SUM 计算每个邻域中的字段值的总和。
  • VARIETY 计算每个邻域中的唯一字段值的数目。
String

返回值

名称说明数据类型
out_raster

输出点统计栅格。

Raster

代码实例

PointStatistics 示例 1(Python 窗口)

此例为落在每个输出栅格像元周围的圆形邻域内的输入 shapefile 点要素确定统计数据(总和)。

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outPointStats = PointStatistics("ca_ozone_pts.shp", "OZONE", 500, 
                                NbrCircle(10000, "MAP"), "SUM")
outPointStats.save("C:/sapyexamples/output/pointstatsout")
PointStatistics 示例 2(独立脚本)

此例为落在每个输出栅格像元周围的圆形邻域内的输入 shapefile 点要素确定统计数据(平均值)。

# Name: PointStatistics_Ex_02.py
# Description: Calculates a statistic on points over a specified 
#    neighborhood outputting a raster.
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inPointFeatures = "ca_ozone_pts.shp"
field = "OZONE"
cellSize = 500
neighborhood = NbrCircle(6000, "MAP")

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Execute PointStatistics
outPointStatistics = PointStatistics(inPointFeatures, field, cellSize,
                                     neighborhood, "MEAN")

# Save the output 
outPointStatistics.save("C:/sapyexamples/output/pointstatout")

环境

相关主题

许可信息

ArcGIS for Desktop Basic: 需要 Spatial Analyst
ArcGIS for Desktop Standard: 需要 Spatial Analyst
ArcGIS for Desktop Advanced: 需要 Spatial Analyst
5/10/2014