NbrWeight (arcpy.sa)

サマリ

Defines a weight neighborhood which is created using a kernel file specifying the values to multiply the cell by that are within the neighborhood.

NbrWeight neighborhood FocalStatistics image
NbrWeight neighborhood for the FocalStatistics function.
NbrWeight neighborhood BlockStatistics image
NbrWeight neighborhood for the BlockStatistics tool.

説明

Tools that use neighborhood weight object: Block Statistics and Focal Statistics.

The weight neighborhood is specified using a kernel file. The kernel file identifies which cell positions should be included within the neighborhood and the weights that will be used to multiply the cell values by on the input raster.

For focal tools the x,y position for the processing cell within the neighborhood, with respect to the upper-left corner of the neighborhood, is determined by the following equations:

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

If the input number of cells is even, the x and y coordinates are computed using truncation.

The kernel file:

構文

NbrWeight (inKernelFile)
パラメータ説明データ タイプ
inKernelFile

The inKernelFile is an ASCII text file that defines the shape of the neighborhood and the weight of each cell in that neighborhood. A value of 0 for a cell position indicates that the cell is not a member of the neighborhood, and a number at a corresponding cell's position indicates that the cell value be included as a member of the neighborhood. The nonzero value will also serve as the weight to multiply the corresponding cell value.

File

特性

プロパティ説明データ タイプ
inKernelFile
(読み書き)

The inKernelFile is an ASCII text file that defines the shape of the neighborhood and the weight of each cell in that neighborhood. A value of 0 for a cell position indicates that the cell is not a member of the neighborhood, and a number at a corresponding cell's position indicates that the cell value be included as a member of the neighborhood. The nonzero value will also serve as the weight to multiply the corresponding cell value.

String

コードのサンプル

NbrWeight example 1 (Python window)

Demonstrates how to create a NbrWeight class and use it in the BlockStatistics tool within the Python window.

import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = "C:/sapyexamples/data"
outNbrWF = BlockStatistics("block", NbrWeight("weight.txt"))
outNbrWF.save("C:/sapyexamples/output/blstatsnbrwf2")
NbrWeight example 2 (stand-alone script)

Implements the BlockStatistics tool using the NbrWeight class.

# Name: NbrWeight_Ex_02.py
# Description: Uses the NbrWeight 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
inWeightFile = "C:/data/weight.txt"
myNbrWeight = NbrWeight(inWeightFile)

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

# Execute BlockStatistics
outBlStats =  BlockStatistics(inRaster, myNbrWeight, "MINIMUM", "DATA")

# Save the output 
outBlStats.save("C:/sapyexamples/output/blstat_wght3")

関連トピック

9/14/2013