NbrIrregular (arcpy.sa)

摘要

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

插图

NbrIrregular 邻域 FocalStatistics 图像
FocalStatistics 函数的 NbrIrregular 邻域。
NbrIrregular 邻域 BlockStatistics 图像
BlockStatistics 工具的 NbrIrregular 邻域。

讨论

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

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

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

 x = (width + 1)/2
 y = (height + 1)/2

如果输入像元数为偶数,则可通过截断操作来计算 x 和 y 坐标。

核文件:

语法

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
(读写)

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.

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)

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

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

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

相关主题

5/10/2014