NbrWedge (arcpy.sa)
摘要
定义通过指定半径和两个角度(以地图单位或像元数为单位)而创建的楔形邻域。
插图
讨论
使用楔形邻域对象的工具包括:块统计、焦点统计、点统计和点密度。
楔形由半径、起始角度、终止角度及单位进行指定。楔形按逆时针方向从起始角延伸到终止角。角度为算术度(基于 x 轴正向按逆时针方向进行测量)。也可使用负角度。
半径用像元单位或地图单位标识并且沿着垂直于 x 轴或 y 轴的方向进行测量。采用地图单位指定半径时,会将其转换为以像元为单位的半径。所得的以像元为单位的半径会生成一个区域,该区域能够近似地表示出使用原始的地图单位为半径时计算的区域。中心位于楔形内的所有像元都将包括在邻域的处理范围内。
语法
参数 | 说明 | 数据类型 |
radius |
The radius is the distance from the corner of the wedge to the outer limit of the wedge. The radius is an integer or floating-point value. (默认值为 3) | Double |
startAngle |
The startAngle is an integer or floating-point value from 0 to 360. The start angle is measured counterclockwise from the positive x-axis (3:00 on a clock) to the closest edge of the wedge. (默认值为 0) | Double |
endAngle |
The endAngle is an integer or floating-point value from 0 to 360. The end angle is measured counterclockwise from the positive x-axis (3:00 on a clock) to the outer edge of the wedge. (默认值为 90) | Double |
units |
Defines the units of the neighborhood.
(默认值为 CELL) | String |
属性
属性 | 说明 | 数据类型 |
radius (读写) |
The radius is the distance from the corner of the wedge to the outer limit of the wedge. The radius is an integer or floating-point value. | Double |
startAngle (读写) |
The startAngle is a value from 0 to 360. It can be integer or floating-point. The start angle is measured counterclockwise from the positive x-axis (3:00 on a clock) to the closest edge of the wedge. | Double |
endAngle (读写) |
The endAngle is a value ranging from 0 to 360. It can be integer or floating-point. The endAngle is measured counterclockwise from the positive x-axis (3:00 on a clock) to the outer edge of the wedge. | Double |
units (读写) |
Defines the units of the neighborhood. | String |
代码实例
演示如何创建 NbrWedge 类以及如何在 Python 窗口的 BlockStatistics 工具中使用该类。
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outNbrWedge = BlockStatistics("block", NbrWedge(5, 10.5, 40, "MAP"))
outNbrWedge.save("C:/sapyexamples/output/blstatsnbrw2")
使用 NbrWedge 类执行 BlockStatistics 工具。
# Name: NbrWedge_Ex_02.py
# Description: Uses the NbrWedge 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
radius = 5
startAngle = 5
endAngle = 10
myNbrWedge = NbrWedge(radius, startAngle, endAngle, "")
# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")
# Execute BlockStatistics
outBlkStats = BlockStatistics(inRaster, myNbrWedge, "MINIMUM", "DATA")
# Save the output
outBlkStats.save("C:/sapyexamples/output/blkst_wedge4")