Skip To Content

Make Masks From Rules


Creates polygon masks for features based on color rules.


  • This tool will process the rule file and for each rule, find the intersection of symbolized features based on the colors or symbol parts defined in the rule. It will create a masking polygon at the intersection of the symbolized features. The rule file allows for storing masks in multiple feature classes.

  • The color rules are defined in an XML file. A rule specifies that symbolized features of a particular color be masked by a source feature that has a particular color.

    The following example rule is based on a map specification that dictates that a mask will be created for any location where the outline of a black symbol (color of 0,0,0,100 CMYK) intersects a piece of black annotation.

            <!-- CMYK Feature Masks -->
            <Mask Size=".1" Units="Points" Type="Box"/>
            <Source SymbolPart="Text_Only" LayerType="AnnotationLayer"/>
            <Target SymbolPart="Outline_Only" LayerType="FeatureLayer"/>
                <Rule Name="FeatureMasks_Black_CMYK_1pt">
                    <Source Color="0,0,0,100"/>
                        <Target Color="0,0,0,100"/>
  • The size of the mask that will be generated is dependent on the map scale. Ensure that you have set an appropriate reference scale on your map or zoomed the map to the desired scale. The scale should match the scale of the output product to which the mask will be applied.

  • When creating masks for annotation layers, the annotation should be created at the same scale as the output product.

  • The projection of the map should match the projection of the output product to which the masks will be applied. If the mask features will be stored in an existing feature dataset, the coordinate system of the feature dataset should match the projection of the output product.

  • The MaskFeatureClass tag in the mask .xml file determines the name of the mask feature class that will be created. If a feature class with the same name already exists in the database chosen for the output feature dataset, the feature class will be deleted and re-created. Masks will not be appended to existing feature classes.

  • Masks will be created for all layers in the chosen map that have symbol parts that use the specified colors. To prevent masks from being created for a specific layer, add the name of the layer to the Target Exclusions tag.

  • Template mask .xml files are included with the product files for Esri Production Mapping and Esri Defense Mapping.


MakeMasksFromRules_topographic (in_map, rule_file, out_feature_dataset)
ParameterExplanationData Type

The input map containing symbolized features.


The XML file containing rules that define how features should be masked based on colors and symbol parts.


The output feature dataset. The tool will create a feature dataset containing polygon feature classes that will be used for masking. The spatial reference for the feature dataset will be taken from the map for which masks are generated.

Feature Dataset

Code sample

MakeMasksFromRules example (stand-alone script)

The following code sample creates masks for annotation features based on the rules defined in the rule XML file.

# Name:
# Description: This script creates masks for annotation features based on the rules defined in the rule xml file

# Import System Modules
import arcpy

# Check Out Extensions

# Setting the environment
arcpy.env.overwriteOutput = True

# Setting Local Variables
in_map = r'C:\Data\NewZealandHistoricBuildings.mapx'
rule_file = r'C:\Data\NewZealandHistoricBuildingAnno_Masking_Rules.xml'
out_feature_dataset = r'C:\Data\Label_your_map.gdb\Masks'

# Calling the Make Masks From Rules to create mask features for the annotation features defined in the rule_file
arcpy.topographic.MakeMasksFromRules(in_map, rule_file, out_feature_dataset)

# Getting all messages, warnings, and errors from the tool run and printing the results back to the user
messages = arcpy.GetMessages(0)
warnings = arcpy.GetMessages(1)
errors = arcpy.GetMessages(2)
arcpy.AddMessage('Tool Messages: {}\nTool Warnings: {}\nTool Errors{}\n'.format(messages, warnings, errors))

# Check In Extensions


This tool does not use any geoprocessing environments.

Licensing information

  • Basic: No
  • Standard: Requires Production Mapping
  • Advanced: Requires Production Mapping

Related topics