Extracts the cells of a raster based on a rectangle.
Command line and Scripting
When a multiband raster is specified as input, a new multiband raster will be created as output. Each individual band in the input multiband raster will be analyzed accordingly. The default output format is an ESRI grid stack. Note that the name of an ESRI grid stack cannot start with a number, use spaces, or be more than 9 characters in length.
If the input is a layer created from a multiband raster with more than three bands, the extraction operation will only consider the bands that were loaded (symbolized) by the layer. As a result, the output multiband raster can only have three bands, corresponding to those used in the display of the input layer.
ExtractByRectangle_sa (in_raster, rectangle, out_raster, extraction_area)
Data types for geoprocessing tool parametersScript Example
|Input raster (Required)
The input raster from which cells will be extracted.
X minimum and y minimum define the lower-left coordinates of the area to be extracted, and x maximum and y maximum define the upper-right coordinates.
The coordinates are specified in the same map units as the in_raster.
|Output raster (Required)
The raster to be created.
|Extraction area (Optional)
Identifies whether to extract cells inside or outside the input rectangle.
- INSIDE — A keyword specifying that the cells inside the input rectangle should be selected and written to the output raster. All cells outside the rectangle will receive NoData values on the output raster.
- OUTSIDE — A keyword specifying that the cells outside the input rectangle should be selected and written to the output raster. All cells inside the rectangle will receive NoData values on the output raster.
# Extracts the cells of a raster based on a rectangle.
# Requirements: None
# Author: ESRI
# Date: Sept 6, 2005
# Import system modules
# Create the Geoprocessor object
gp = arcgisscripting.create()
# Set local variables
InRaster = "C:/data/raster1"
InRectangle = "20 30 40 80"
OutRaster = "C:/data/final_1"
# Check out Spatial Analyst extension license
# Process: ExtractByRectangle
gp.ExtractByRectangle_sa(InRaster, InRectangle, OutRaster, "INSIDE")
# If an error occurred while running a tool, then print the messages.
Map Algebra syntax