Compare Layer to Snapshot (Production Mapping)

License Level:BasicStandardAdvanced

Summary

This tool, in conjunction with the Calculate Layer Snapshot tool, selects features that have had geometry, extent, or symbology changes.

Usage

Syntax

CompareLayerToSnapshot_production (in_features, snapshot_field_name, invert_selection)
ParameterExplanationData 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.

  • SELECT_UNCHANGEDSelect only features whose geometries, extents, and symbols have not changed.
  • SELECT_CHANGEDSelect only features whose geometries, extents, and symbols have changed. This is the default.
Boolean

Code Sample

CompareLayerToSnapshot example (Python window)

The following Python window script demonstrates how to use the CompareLayerToSnapshot tool. To use this script:

  1. Add the PolbndA feature class from the SoCal.gdb sample database to ArcMap.
  2. Add a long integer field to PolbndA called polbnd_extent_info.
  3. Run the CalculateLayerSnapshot tool against PolbndA, selecting polbnd_extent_info as the Snapshot Field.
  4. Change the symbology of PolbndA in ArcMap.
  5. 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")
CompareLayerToSnapshot example 2 (Stand–alone Python script)

The following stand-alone Python script demonstrates how to use the CompareLayerToSnapshot tool. To run this script:

  1. Copy the SoCal.gdb sample Production Mapping geodatabase to c:\data.
  2. Display the PolbndA feature class in ArcMap.
  3. Add a new field, pol_ext_info, type LONG, to PolbndA.
  4. Run the Calculate Layer Snapshot tool on PolbndA, using the pol_ext_info field as an input.
  5. 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")

Environments

Related Topics

Licensing Information

ArcGIS for Desktop Basic: No
ArcGIS for Desktop Standard: Requires Production Mapping
ArcGIS for Desktop Advanced: Requires Production Mapping
12/18/2014