Extract by Rectangle

Extracts the cells of a raster based on a rectangle.


Usage tips

Command line and Scripting

Syntax

ExtractByRectangle_sa (in_raster, rectangle, out_raster, extraction_area)
Parameter Explanation Datatype
Input raster (Required)

The input raster from which cells will be extracted.

Composite Geodataset
Rectangle (Required)

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.

Envelope
Output raster (Required)

The raster to be created.

Raster Dataset
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.

String
Data types for geoprocessing tool parameters

Script Example

# ExtractByRectangle_sample.py
# Description: 
#   Extracts the cells of a raster based on a rectangle.
# Requirements: None
# Author: ESRI
# Date: Sept 6, 2005

# Import system modules
import arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

try:
    # Set local variables
    InRaster = "C:/data/raster1"
    InRectangle = "20 30 40 80"
    OutRaster = "C:/data/final_1"

    # Check out Spatial Analyst extension license
    gp.CheckOutExtension("Spatial")

    # Process: ExtractByRectangle
    gp.ExtractByRectangle_sa(InRaster, InRectangle, OutRaster, "INSIDE")

except:
    # If an error occurred while running a tool, then print the messages.
    print gp.GetMessages()

Map Algebra syntax

See SelectBox


ArcObjects syntax

See Rectangle


See Also

  • Extract by Circle
  • Extract by Points
  • Extract by Polygon
  • An overview of the Extraction tools