Extract by Mask

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


Illustration

Extract by Mask illustration

Usage Tips

Syntax

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

Input raster.

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

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

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

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

except:
    # 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