NbrIrregular (arcpy.sa)

Zusammenfassung

Defines an irregular neighborhood which is created by a kernel file.

Bild

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

Diskussion

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

The kernel file specifies which cell positions should be included within the neighborhood.

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:

Syntax

NbrIrregular (inKernelFile)
ParameterErläuterungDatentyp
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

Eigenschaften

EigenschaftErläuterungDatentyp
inKernelFile
(Lesen und schreiben)

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

Codebeispiel

NbrIrregular example 1 (Python window)

Demonstrates how to create a NbrIrregular 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"
outNbrKF = BlockStatistics("block", NbrIrregular("irreg.txt"))
outNbrKF.save("C:/sapyexamples/output/blstatsnbri2")
NbrIrregular example 2 (stand-alone script)

Implements the BlockStatistics tool using the NbrIrregular class.

# 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")

Verwandte Themen

9/12/2013