Extract by Mask |
|
Release 9.3
Last modified September 7, 2011 |
![]() ![]() ![]() Print all topics in : "Extraction (Spatial Analyst)" |
Extracts the cells of a raster that correspond to the areas defined by a mask.
Illustration
ExtractByMask_sa InRas1 InRas2 OutRas
Usage tips
Command line and Scripting
If the input raster values are integer, the output raster will be integer. If the input is floating point, the output will be floating point.
When input raster or feature mask data is raster, the values for non-NoData input cell locations are copied to the output raster. Tools that can create the mask raster include Con, Test, and the extraction group.
Extract by Mask is similar to setting the Mask option in the environment, except that the mask used in Extract by Mask is only used on the immediate instance, while a mask set in the environment is applied to all tools until it is changed or disabled.
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.
When a multiband raster is specified for the input raster mask, only the first band will be used in the operation
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.
The following environment settings affect this tool:
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 |
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 |
# 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