ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Mask (Environment setting)

  • Illustration
  • Usage notes
  • Dialog syntax
  • Scripting syntax

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
Mask identifies the areas in the analysis extent to be included in the tool execution.

Usage notes

  • Setting an analysis mask means that processing will only occur on locations that fall within the mask, and all locations outside of it will be assigned NoData in the output.
    Note:

    The Mask environment applies to Spatial Analyst and Geostatistical Analyst extension tools that output a raster. It also applies to tools in the Raster Interpolation, Raster Math, Raster Reclass, and Raster Surface toolsets of the 3D Analyst extension that output a raster.

  • The mask can be raster or feature data.
  • If the analysis mask is a raster, all cells that have a value will be considered to define the mask. Cells in a mask raster that are NoData will be considered to be outside the mask and will be NoData in the output.

    Tools such as Reclassify and Con can help create a raster analysis mask.

  • If the analysis mask is a feature class or feature layer, it will be converted internally to a raster upon execution. For this reason, ensure that the Cell Size and Snap Raster environments are set appropriately for your analysis.

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 comprise 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 upon execution.

Scripting syntax

arcpy.env.mask = mask_source

ParameterExplanation

mask_source

The dataset that defines the mask.

The dataset can be either a raster or feature data. If it is a raster dataset, 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 extension 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 a Spatial Analyst 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

  • What is a geoprocessing environment setting?
  • Setting geoprocessing environments

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal