Shrink |
|
Release 9.2
Last modified January 3, 2008 |
Print all topics in : "Generalization (Spatial Analyst)" |
Shrinks the selected zones by a specified number of cells.
Learn more about how Shrink works
Illustration
Usage tips
Command line and Scripting
The input raster must be an integer raster.
The number of cells must be a positive integer.
The zone values must be integers. They can be in any order.
When two adjacent regions are part of the selected set to shrink, there is no change at the boundary between them.
NoData has the same priority as any valid value to invade areas vacated by shrinking selected values. Therefore, if a selected value is adjacent to NoData, it may become NoData after shrinking.
The following environment settings affect this tool:
Map Algebra
The <in_grid> must be an integer raster, and <ncells> and all values within the LIST, FILE, or TABLE must be integer.
The zone values in an ASCII FILE or INFO TABLE must be sorted in ascending order.
The ASCII file used with the FILE option can be one column or two. A one-column file indicates single values will be specified for selection. A two-column file indicates ranges of values will be specified for selection. For example: To select cells with value 1 and 5, the FILE would be:
1 5To select cells with a value between 1 and 5, inclusively, the FILE would be:
1 5
The INFO table used with the TABLE option selects only single values from the {item} specified.
When two adjacent regions are part of the selected set to Shrink, there is no change at the boundary between them.
NoData has the same priority as any valid value to invade areas vacated by the shrink of selected values. Therefore, if a selected value is adjacent to NoData, it may become NoData following Shrink.
Learn more about how to specify the input raster dataset in the Map Algebra expression of Raster Calculator.
ArcObjects
Valid input for the raster to ArcObjects is a Raster, RasterDataset, RasterBand, or RasterDescriptor.
The input raster must be integer.
The numberCells input must be integer.
A zoneList is used to specify the zones to shrink. A zoneList can be created using the following code:
Dim ZoneList As Variant Dim ZoneArr(0 to 2) as Integer ZoneArr(0) = 860 ZoneArr(1) = 880 ZoneArr(2) = 1000 ZoneList = ZoneArr()
When two adjacent regions are part of the selected set to shrink, there is no change at the boundary between them.
NoData has the same priority as any valid value to invade areas vacated by the shrink of selected values. Therefore, if a selected value is adjacent to NoData, it may become NoData following Shrink.
The output from the ArcObjects method is a raster object.
Command line syntax
An overview of the Command Line window
Shrink_sa <in_raster> <out_raster> <number_cells> <zone_values; zone_values...>
Parameter | Explanation | Data Type |
<in_raster> |
Input raster. |
Composite Geodataset |
<out_raster> |
The raster to be created. |
Raster Dataset |
<number_cells> |
The number of cells by which to shrink each specified zone. |
Long |
<zone_values; zone_values...> |
List of zone values to shrink. |
Long |
Aggregate_sa C:/data/ras_1 C:/data/final_1 1 2
Scripting syntax
About getting started with writing geoprocessing scripts
Shrink_sa (in_raster, out_raster, number_cells, zone_values)
Parameter | Explanation | Data Type |
in_raster (Required) |
Input raster. |
Composite Geodataset |
out_raster (Required) |
The raster to be created. |
Raster Dataset |
number_cells (Required) |
The number of cells by which to shrink each specified zone. |
Long |
zone_values (Required) |
List of zone values to shrink. |
Long |
# Shrink_sample.py # Description: # Thins rasterized linear features by reducing the number of # cells representing the width of the features. # Requirements: None # Author: ESRI # Date: Sept 6, 2005 # Import system modules import arcgisscripting # Create the Geoprocessor object gp = arcgisscripting.create() try: # Set local variables outRaster = "C:/data/final_1" inRaster = "C:/data/ras_1" # Check out Spatial Analyst extension license gp.CheckOutExtension("Spatial") # Process: Majority Filter... gp.Shrink_sa(inRaster, outRaster, "1", "'2'") except: # If an error occurred while running a tool, then print the messages. print gp.GetMessages()
Map Algebra syntax
Shrink(<grid>, <ncells>, LIST, <value_list>)
Parameter | Explanation |
(<grid>, <ncells>, LIST, <value_list>) | The zones to shrink will be listed. |
(<grid>, <ncells>, FILE, <select_file>) | The zones to shrink will be read from an ASCII file. |
(<grid>, <ncells>, TABLE, <select_table>, {item}) | The zones to shrink will be read from a specified item in an INFO file. |
<grid> | The name of a raster. |
<ncells> | The number of cells by which to shrink each selected zone. |
LIST | Keyword indicating that the zones to select will be listed on the command line. |
<value_list> | A listing of values from the value attribute table.
This list can contain no more than 20 values. |
FILE | Keyword indicating that the zones to select will be listed in an ASCII text file. |
<select_file> | The name of an ASCII text file containing the value or value ranges from the value attribute table to be selected. |
TABLE | Keyword indicating that the zones to select will be listed as single values in an INFO file. |
<select_table> | The name of a table of single values to be selected. |
{item} | The name of the item in the INFO table from which values in the <select_table> will be selected.
The default is Value. |
shrink(ingrid, 1, list, 5) shrink(ingrid, 2, list, 6, 0, 9, 1) shrink(ingrid, 4, file, shrfile) shrink(ingrid, 1, table, shrtable)
ArcObjects syntax
IGeneralizeOp::Shrink (raster As IGeoDataset, numberCells As Long, zoneList As Variant) As IGeoDataset
Parameter | Explanation |
raster | An input Raster, RasterDataset, RasterBand, or RasterDescriptor. |
numberCells | The number of cells by which to shrink each selected zone. |
zoneList | A listing of zones from the value attribute table. |
' Create the RasterGeneralizeOp object Dim pGeneralizeOp As IGeneralizeOp Set pGeneralizeOp = New RasterGeneralizeOp ' Declare the input raster object Dim pInputDataset As IGeoDataset ' Calls function to open a raster dataset from disk Set pInputDataset = OpenRasterDataset("D:\SpatialData", "inputdataset") ' This example is assuming the input raster is integer ' type and contains values: 860, 880, 1000 and will be ' defined in the following zone list Dim ZoneList As Variant Dim ZoneArr(0 to 2) as Integer ZoneArr(0) = 860 ZoneArr(1) = 880 ZoneArr(2) = 1000 ZoneList = ZoneArr() ' Declare the output raster object Dim pOutputRaster As IGeoDataset ' Calls the method Set pOutputRaster = pGeneralizeOp.Shrink(pInputDataset, 3, ZoneList)