NbrIrregular

需要 Spatial Analyst 许可。

获得 Image Analyst 许可后可用。

摘要

用于定义由核文件创建的不规则邻域。

插图

FocalStatistics 函数的 NbrIrregular 邻域
FocalStatistics 函数的 NbrIrregular 邻域示例。
BlockStatistics 函数的 NbrIrregular 邻域
BlockStatistics 函数的 NbrIrregular 邻域示例。

说明

使用不规则邻域对象的工具包括:块统计焦点统计

许可:

如果您拥有 Image Analyst 扩展模块许可,也可以使用该类,但仅限于焦点统计工具。

核文件可指定应包含在邻域范围内的各像元位置。

对于焦点工具,邻域范围内待处理像元相对于邻域左上角的 x,y 位置可通过以下方程式来确定:

x = (宽度 + 1)/2 y = (高度 + 1)/2

如果输入像元数为偶数,则将使用截断来计算 x 和 y 坐标。

核文件:

  • 核文件是一个 ASCII 文本文件,用于定义不规则邻域的值和形状。

  • 第一行指定了邻域的宽度和高度(x 方向的像元数,后跟一个空格,以及 y 方向的像元数)。

  • 随后的几行将提供邻域中每个位置的值。 这些值的输入配置与其所代表的邻域中显示的配置相同。 每个值之间必须存在一个空格。

  • 核文件中的值应为 0 或 1。 但是,任何非 0 的值都将被视为 1。

  • 某像元位置的值为 0(非空格)表示该像元不属于该邻域,将不会用于邻域处理。 而值为 1 则表示该值对应的像元(和像元值)属于该邻域。

语法

NbrIrregular (inKernelFile)
参数说明数据类型
inKernelFile

The irregular inKernelFile is an ASCII text file that defines the shape of an irregular neighborhood. A value of 0 for a cell position indicates that the cell is not a member of the neighborhood, and a nonzero number at a corresponding cell's position indicates that the cell value be included as a member of the neighborhood.

File

属性

属性说明数据类型
inKernelFile
(可读写)

不规则的 inKernelFile 是一种 ASCII 文本文件,用于定义不规则邻域的形状。 像元位置值为 0 表示该像元并非领域的成员,而像元位置对应非零数值则表示该像元值已被包括在领域成员中。

String

代码示例

NbrIrregular 示例 1(Python 窗口)

演示如何创建 NbrIrregular 类以及如何在 Python 窗口的 BlockStatistics 工具中使用该类。

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outNbrKF = BlockStatistics("block", NbrIrregular("irreg.txt"))
outNbrKF.save("C:/sapyexamples/output/blstatsnbri2")
NbrIrregular 示例 2(独立脚本)

使用 NbrIrregular 类执行 BlockStatistics 工具。

# Name: NbrIrregular_Ex_02.py
# Description: Uses the NbrIrregular object to execute BlockStatistics tool.
# 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
inRaster = "block"

# Create the Neighborhood Object
inKernelFile = "C:/data/irreg.txt"
myNbrIrreg = NbrIrregular(inKernelFile)

# Execute BlockStatistics
outBlkStat =  BlockStatistics(inRaster, myNbrIrreg, "MINIMUM", "DATA")

# Save the output 
outBlkStat.save("C:/sapyexamples/output/blstat_irr3")

相关主题