Compare Layer to Snapshot (Production Mapping)
Summary
This tool, in conjunction with the Calculate Layer Snapshot tool, selects features that have had geometry, extent, or symbology changes.
Usage
-
This tool accepts points, polylines, polygons, and annotation feature layers as input.
The Calculate Layer Snapshot tool creates data required by this tool. You must enable a feature class for snapshot change tracking by running the Calculate Layer Snapshot tool first.
This tool compares the extent value stored in each feature's Snapshot Field to the present value of geometry, extent, and symbol. If any discrepancies are found between the two values, the tool will add a feature to the Input Features selection set. Discrepancies can include geometry modifications such as splitting or extending a polygon, moving a geometry, or changing any symbol property.
To run this tool against multiple inputs, each input layer must have a commonly named Snapshot Field attribute.
Syntax
Parameter | Explanation | Data Type |
in_features [in_features,...] |
The input list of feature layers and feature classes to check for geometry and symbology changes. | Layer |
snapshot_field_name |
The field name containing the checksum values created by Calculate Layer Snapshot. | Field |
invert_selection |
Specifies if the tool should select changed features or invert the selection to unchanged features.
| Boolean |
Code Sample
The following Python window script demonstrates how to use the CompareLayerToSnapshot tool. To use this script:
- Add the PolbndA feature class from the SoCal.gdb sample database to ArcMap.
- Add a long integer field to PolbndA called polbnd_extent_info.
- Run the CalculateLayerSnapshot tool against PolbndA, selecting polbnd_extent_info as the Snapshot Field.
- Change the symbology of PolbndA in ArcMap.
- Add the following code to the python window in ArcMap.
arcpy.env.workspace = "C:/data/SoCal.gdb"
arcpy.CompareLayerToSnapshot_production("PolbndA","polbnd_extent_info","FALSE")
desc = arcpy.Describe("PolbndA")
selectedFids = desc.FIDSet
if len(selectedFids) > 0:
arcpy.CopyFeatures_management("PolbndA","ChangedPoliticalBounds")
The following stand-alone Python script demonstrates how to use the CompareLayerToSnapshot tool. To run this script:
- Copy the SoCal.gdb sample Production Mapping geodatabase to c:\data.
- Display the PolbndA feature class in ArcMap.
- Add a new field, pol_ext_info, type LONG, to PolbndA.
- Run the Calculate Layer Snapshot tool on PolbndA, using the pol_ext_info field as an input.
- Close ArcMap and run the following script.
# Name: CompareLayerToSnapshot.py
# Description: Writes changed features (in this example - symbols) to a new feature class
import arcpy
# check out a production mapping extension license
arcpy.CheckOutExtension("Foundation")
# set the current workspace
arcpy.env.workspace = "C:/data/SoCal.gdb"
# make a feature layer from the PolbndA feature class
arcpy.MakeFeatureLayer_management("PolbndA","polbndlayer")
# check for changed features in the pol_ext_info field
arcpy.CompareLayerToSnapshot_production("polbndlayer","pol_ext_info","FALSE")
# describe the feature layer to access the the selected set
desc = arcpy.Describe("polbndlayer")
# FIDSet will contain the selected features
selectedFids = desc.FIDSet
# As the symbol in polbndlayer is different than what was written in
# the pol_ext_info field, there should be a selection set.
# If there are selectedFids (a selection set), write them to a new feature
# class in the current workspace.
if len(selectedFids) > 0:
arcpy.CopyFeatures_management("polbndlayer","ChangedPoliticalBounds")
# check the extension in
arcpy.CheckInExtension("Foundation")