Show Navigation | Hide Navigation
You are here:
Extensions > Spatial Analyst > Spatial Analyst functional reference > Generalization (Spatial Analyst)

Shrink

Release 9.2
Last modified January 3, 2008
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Generalization (Spatial Analyst)"


Related Topics

Shrinks the selected zones by a specified number of cells.

Learn more about how Shrink works


Illustration

Shrink illustration

Usage tips

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
Data types for geoprocessing tool parameters


Command line example

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

Data types for geoprocessing tool parameters


Script example

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

Shrink(<grid>, <ncells>, FILE, <select_file>)

Shrink(<grid>, <ncells>, TABLE, <select_table>, {item})

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.

Map Algebra example

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.

ArcObjects example

' 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)

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.