ArcGIS for Desktop

  • 文档
  • 合约
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

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

ArcGIS for Desktop

全面的专业性 GIS

ArcGIS for Server

面向企业的 GIS

ArcGIS for Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

帮助

  • 主页
  • 入门
  • 制图
  • 分析
  • 管理数据
  • 工具
  • 更多...

NbrRectangle

需要 Spatial Analyst 许可。

  • 摘要
  • 插图
  • 讨论
  • 语法
  • 属性
  • 代码实例

摘要

定义通过指定以地图单位或像元数为单位的高度和宽度而创建的矩形邻域。

插图

FocalStatistics 函数的 NbrRectangle 邻域
FocalStatistics 函数的 NbrRectangle 邻域示例。
BlockStatistics 函数的 NbrRectangle 邻域
BlockStatistics 函数的 NbrRectangle 邻域示例(宽度 = 6 像元,高度 = 4 像元)。

讨论

使用邻域矩形对象的工具包括:块统计、焦点统计、点统计和点密度。

通过提供以像元或地图单元为单位的宽度和高度值,指定矩形邻域。

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

 x = (width of the neighborhood + 1)/2
 y = (height of the neighborhood + 1)/2

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

仅将中心在定义对象内的像元作为矩形邻域的一部分进行处理。

语法

 NbrRectangle ({width}, {height}, {units})
参数说明数据类型
width

The width of the rectangle neighborhood.

If only the width is specified, the resulting neighborhood is a square.

(默认值为 3)

Double
height

The height of the rectangle neighborhood.

If only the height is specified, the resulting neighborhood is a square.

(默认值为 3)

Double
units

Defines the units of the neighborhood.

  • CELL —The unit of measurement is in cells.
  • MAP —The units are in map coordinates.

(默认值为 CELL)

String

属性

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

The width of the rectangle neighborhood.

If only the width is specified, the height will default to the same as the width, resulting in a square neighborhood.

Double
height
(读写)

The height of the rectangle neighborhood.

If only the height is specified, the width will default to the same as the height, resulting in a square neighborhood.

Double
units
(读写)

Defines the units of the neighborhood.

String

代码实例

NbrRectangle 示例 1(Python 窗口)

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

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outNbrRec = BlockStatistics("block", NbrRectangle(4, 5, "MAP"))
outNbrRec.save("C:/sapyexamples/output/blstatsnbrr2")
NbrRectangle 示例 2(独立脚本)

使用 NbrRectangle 类执行 BlockStatistics 工具。

# Name: NbrRectangle_Ex_02.py
# Description: Uses the NbrRectangle 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
width = 5
height = 6
myNbrRec = NbrRectangle(width, height, "MAP")

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

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

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

相关主题

  • Spatial Analyst 类概述
  • 邻域类概述
有关此主题的反馈?

ArcGIS for Desktop

  • 主页
  • 文档
  • 合约
  • 支持

ArcGIS 平台

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

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明