描述
Applies symbol layer masking to feature layers in a map based on an XML rule file and mask features created by the Make Mask From Rules tool.
注:
A product file installer is available for ArcGIS Production Mapping and ArcGIS Defense Mapping. The product files contain predefined XML masking rule files that can be used for cartographic production.
Learn more about Defense Mapping product files and Production Mapping product files.
使用方法
The Make Mask From Rules tool must be run before this tool to create the mask feature classes stored in the mask feature dataset. The mask features created by the Make Mask From Rules tool are used to define the extent of the masks applied to the layers in the map.
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.
<RuleGroup> <!-- CMYK Feature Masks --> <Mask Size=".1" Units="Points" Type="Box"/> <Source SymbolPart="Text_Only" LayerType="AnnotationLayer"/> <Target SymbolPart="Outline_Only" LayerType="FeatureLayer"/> <TargetExclusions></TargetExclusions> <Rules> <Rule Name="FeatureMasks_Black_CMYK_1pt"> <MaskFeatureClass>FeatureMasks_Black_CMYK_1pt</MaskFeatureClass> <Source Color="0,0,0,100"/> <Targets> <Target Color="0,0,0,100"/> </Targets> </Rule> </Rules> </RuleGroup>
注:
Sample XML masking files are delivered in the Defense Mapping and Production Mapping product file installs. Use these sample XML files as a template to create custom masking rules.
The XML rule file is used to determine the symbol layers (such as fill, outline, and so on) that require masking based on the color of the symbol layer.
Any masks currently applied to the layers in the map will be removed when this tool is run. The resulting map will only have masks applied to layers that meet the results defined in the mask XML.
Set the coordinate system of the map to match the projection of the final printable map or other output product before applying masks. The coordinate system of the map should also match the coordinate system of the mask feature dataset.
注:
If the mask feature dataset is not projected to the proper coordinate system, the masks will not align with the features in the final printable map. Set the proper coordinate system on the masks feature dataset before running the Make Masks From Rules tool to avoid mask projection issues.
语法
ApplyMasksFromRules(in_map, rule_file, in_feature_dataset)
参数 | 说明 | 数据类型 |
in_map | The input map containing symbolized features such as a map in a project or a MAPX file on disk. | Map |
rule_file | The XML file containing rules to define how features should be masked based on colors and symbol parts. | File |
in_feature_dataset | The feature dataset containing the masking polygon feature classes created by the Make Mask From Rules tool. | Feature Dataset |
派生输出
名称 | 说明 | 数据类型 |
updated_map | Output map with updated masks. | Map |
代码示例
The following code sample takes masks generated by the MakeMasksFromRules tool and applies them to the features in the specified MAPX file. ApplyMasksFromRules will set symbol level masking on the layers.
# Name: ApplyMasksFromRules_sample.py
# Description: This script takes masks that were generated by the Make Masks from Rules tool and applies them to the
# features in the specified mapx file. This tool will set symbol level masking on the layers.
# Import System Modules
import arcpy
# Check Out Extensions
arcpy.CheckOutExtension('Foundation')
# 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'
in_feature_dataset = r'C:\Data\Label_your_map.gdb\Masks'
# Calling the Apply Masks From Rules to apply masks created in the Make Masks From Rules tool
arcpy.topographic.ApplyMasksFromRules(in_map, rule_file, in_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
arcpy.CheckInExtension('Foundation')
环境
许可信息
- Basic: 否
- Standard: 需要 Production Mapping
- Advanced: 需要 Production Mapping