The output raster represents the height or depth of the spatial structures detected at each cell location.
The Analysis Type parameter value specifies the type of spatial structures to detect. Its two options are Ridge or Valley. The Ridge analysis type detects spatial structures that are taller than their surroundings. The Valley analysis type detects spatial structures that are lower than their surroundings.
The Neighborhood parameter value determines the shape and size of the window used for analysis. Spatial structures whose size or width are smaller than this neighborhood are generally detected.
The available neighborhood shapes are circle, rectangle, and irregular. The irregular neighborhood option is a custom neighborhood defined using a kernel file.
The kernel file is an ASCII text file that specifies the values and shape of the neighborhood. The file can be created with any plain text editor. The file must have a .txt extension and no spaces in the file name.
When the output raster format is .crf, this tool supports the Pyramid raster storage environment. Pyramids will be created in the output by default. For any other output format, this environment is not supported, and pyramids will not be created.
The cells surrounding a processing cell that will be used in the top hat transform calculation. There are several predefined neighborhood types to choose from, or a custom kernel can be defined.
Once the neighborhood type is selected, other parameters can be set to fully define the shape, size, and units of measure. The default neighborhood is a circle with a radius of 3 cells.
The following are the forms of the available neighborhood types:
Circle, Radius, Units type
A circular neighborhood with the given radius. The minimum value for radius is 1 cell, and the maximum value is 2047 cells. The default radius is 3 cells.
Rectangle, Height, Width, Units type
A rectangular neighborhood defined by width and height. The minimum value for width or height is 1 cell, and the maximum value is 4096 cells. The default is a square with a width and height of 3 cells.
Irregular, Kernel file
A custom neighborhood with specifications set by the identified kernel text file. The minimum value for width or height of the kernel is 1 cell, and the maximum value is 4096 cells.
For the circle and rectangle neighborhood types, the distance units for the parameters can be specified in Cell units or Map units. Cell units is the default.
For the irregular neighborhood type, the first line in the kernel file defines the width and height of the neighborhood in numbers of cells. The subsequent lines indicate how the input value that corresponds to that location in the kernel will be processed. A value of 0 in the kernel file indicates that the corresponding location will not be included in the calculation. A value of 1 indicates that the corresponding input cell will be included.
Neighborhood
Analysis Type
(Optional)
Specifies the type of objects that will be detected.
Ridge—Objects that are taller than their surroundings (such as bridges, dams and the ridges of mountains) will be detected. This is the default.
Valley—Objects that are lower than their surroundings (such as water channels and valleys) will be detected.
String
Return value
Label
Explanation
Data type
Output Raster
The output raster.
The cell values of the output raster represent the height or depth of the objects detected at each cell location, depending on the analysis type. When the Ridge option is specified for the Analysis Type parameter, the output values represent the height of the objects detected at each cell location. When the Valley option is specified for the Analysis Type parameter, the output values represent the depth of the objects detected at each cell location.
The cells surrounding a processing cell that will be used in the top hat transform calculation. There are several predefined neighborhood types to choose from, or a custom kernel can be defined.
Once the neighborhood type is selected, other parameters can be set to fully define the shape, size, and units of measure. The default neighborhood is a circle with a radius of 3 cells.
The following are the forms of the available neighborhood types:
NbrCircle({radius}, {units}
A circular neighborhood with the given radius. The minimum value for radius is 1 cell, and the maximum value is 2047 cells. The default radius is 3 cells.
NbrRectangle({width}, {height}, {units})
A rectangular neighborhood defined by width and height. The minimum value for width or height is 1 cell, and the maximum value is 4096 cells. The default is a square with a width and height of 3 cells.
NbrIrregular(inKernelFile)
A custom neighborhood with specifications set by the identified kernel text file. The minimum value for width or height of the kernel is 1 cell, and the maximum value is 4096 cells.
For the irregular neighborhood type, the first line in the kernel file defines the width and height of the neighborhood in numbers of cells. The subsequent lines indicate how the input value that corresponds to that location in the kernel will be processed. A value of 0 in the kernel file indicates that the corresponding location will not be included in the calculation. A value of 1 indicates that the corresponding input cell will be included.
Neighborhood
analysis_type
(Optional)
Specifies the type of objects that will be detected.
RIDGE—Objects that are taller than their surroundings (such as bridges, dams and the ridges of mountains) will be detected. This is the default.
VALLEY—Objects that are lower than their surroundings (such as water channels and valleys) will be detected.
String
Return value
Name
Explanation
Data type
out_raster
The output raster.
The cell values of the output raster represent the height or depth of the objects detected at each cell location, depending on the analysis type. When the RIDGE option is specified for the analysis_type parameter, the output values represent the height of the objects detected at each cell location. When the VALLEY option is specified for the analysis_type parameter, the output values represent the depth of the objects detected at each cell location.
Raster
Code sample
TopHatTransform example 1 (Python window)
This example calculates the top hat transform for an input raster using the Valley analysis type.
from arcpy.sa import *
outRas = TopHatTransform('elevation.tif', "Circle 3 CELL", 'VALLEY')
outRas.save("C:/sapyexamples/output/thtout01.tif")
TopHatTransform example 2 (stand-alone script)
This example calculates the top hat transform for an input raster using the Ridge analysis type.
# Name: TopHatTransform_standalone.py
# Description: Calculates the top hat transform.
# Requirements: Spatial Analyst extension
# Import system modules
import arcpy
from arcpy.sa import *
# Set environment settings
arcpy.env.workspace = "C:/sapyexamples/data"
# Set local variables
inRaster = "elevation.tif"
inNeighborhood = "Circle 90 Map"
inAnalysisType = "RIDGE"
# Run the tool
outRas = TopHatTransform(inRaster, inNeighborhood, inAnalysisType)
# Save the output
outRas.save("C:/sapyexamples/output/thtout02.tif")