Extracts the cells of a raster that correspond to the areas defined by a mask.
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.
|Input raster (Required)||
|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.
|Output raster (Required)||
The raster to be created.
# 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()