Mask (Environment setting)

Tools that honor the Mask environment will only consider those cells that fall within the analysis mask in the operation.

Illustration

Mask identifies the areas in the analysis extent to be included in the tool execution
Mask identifies the areas in the analysis extent to be included in the tool execution.

Usage notes

Dialog syntax

Mask—A dataset that defines which locations in the inputs will be considered in the execution of the tool. If the mask dataset is a raster, all cells with a value will compose the mask. Cells that are NoData in a raster mask will be NoData in the output. If a feature dataset is used as input for the mask, it will be converted internally to a raster on execution.

Scripting syntax

arcpy.env.mask = mask_source

Parameter

Explanation

mask_source

The dataset that defines the mask.

It can be a raster or a feature dataset. If the dataset is a raster, cells that have a value will constitute the mask, and any cells that are NoData in the mask will be NoData in the output.

mask syntax

Script example

This example demonstrates how to set the Mask environment before executing a Spatial Analyst tool.

import arcpy

# Set environment
arcpy.env.workspace = "C:/workspace"

# Set Mask environment
arcpy.env.mask = "C:/data/maskpoly.shp"

# Set local variables
InZones = "C:/data/parcels.shp"
InZoneField = "Parcel_ID"
InValueRaster = "C:/data/Slope"

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

# Process: Calculate the mean slope of each parcel area.
out = arcpy.sa.ZonalStatistics(InZones, InZoneField, InValueRaster, "MEAN","DATA")
out.save("mean_ParSlp")

Related Topics


3/13/2012