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

Extract by Mask

Release 9.3
Last modified September 7, 2011
E-mail This Topic Printable Version Give Us Feedback

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


Related Topics

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


Illustration

Extract by Mask illustration

Command Line:
ExtractByMask_sa InRas1 InRas2 OutRas

Usage tips

Command line syntax
An overview of the Command Line window
ExtractByMask_sa <in_raster> <in_mask_data> <out_raster>

Parameter Explanation Data Type
<in_raster>

The input raster from which cells will be extracted.

Composite Geodataset
<in_mask_data>

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
<out_raster>

The raster to be created.

Raster Dataset
Data types for geoprocessing tool parameters


Command line example

ExtractByMask_sa C:/data/raster1 C:/data/raster2 C:/data/final_1

Scripting syntax
About getting started with writing geoprocessing scripts
ExtractByMask_sa (in_raster, in_mask_data, out_raster)

Parameter Explanation Data Type
in_raster (Required)

The input raster from which cells will be extracted.

Composite Geodataset
in_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
out_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

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