Extract by Mask

Extracts the cells of a raster that correspond to the areas defined by a mask.


Extract by Mask illustration

Usage tips

Command line and Scripting


ExtractByMask_sa (in_raster, in_mask_data, out_raster)
Parameter Explanation Datatype
Input raster (Required)

The input raster from which cells will be extracted.

Composite Geodataset
Input raster or feature mask data (Required)

Input mask data defining areas to extract.

This is a raster or feature dataset.

When the in_mask_data is a raster, NoData cells on the mask will be assigned NoData values on the output raster.

Composite Geodataset
Output raster (Required)

The raster to be created.

Raster Dataset
Data types for geoprocessing tool parameters

Script Example

# ExtractByMask_sample.py
# Description: 
#   Extracts the cells of a raster that correspond with the areas
#   defined by a mask.
# Requirements: None
# Author: ESRI
# Date: Sept 6, 2005

# Import system modules
import arcgisscripting

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

    # Set local variables
    InRaster = "C:/data/raster1"
    InMask = "C:/data/raster2"
    OutRaster = "C:/data/final_1"

    # Check out Spatial Analyst extension license

    # Process: ExtractByMask
    gp.ExtractByMask_sa(InRaster, InMask, OutRaster)

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

Map Algebra syntax

See SelectMask

ArcObjects syntax

See Raster

See Also

  • Extract by Attributes
  • Extract by Rectangle
  • An overview of the Extraction tools