Compare Layer to Snapshot (Production Mapping)
Resumen
This tool, in conjunction with Calculate Layer Snapshot, selects features that have had geometry, extent, or symbology changes.
Uso
-
This tool accepts points, polylines, polygons, and annotation feature layers as input.
Calculate Layer Snapshot creates data required by this tool. You must enable a feature class for snapshot change tracking by running Calculate Layer Snapshot first.
This tool compares the extent value stored in each feature's Extent 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 Extent Field attribute.
To use this tool in a stand-alone script, check out a production mapping foundation license: arcpy.gp.CheckOutExtension("Foundation").
Sintaxis
Parámetro | Explicación | Tipo de datos |
input_features [input_features,...] |
The input list of feature layers and feature classes to check for geometry and symbology changes. | Feature Layer |
extent_field_name |
The field name containing the checksum values created by Calculate Layer Snapshot. | String |
invert_selection (Opcional) |
Specifies if the tool should select changed features or invert the selection to unchanged features.
| Boolean |
Ejemplo de código
The following Python window script demonstrates how to use the CompareLayerToSnapshot function with Production Mapping sample data. The script executes the CompareLayerToSnapshot tool and then checks for any selected features using the Describe function. The script writes any selected features to a new feature class, ChangedPoliticalBounds in the C:/data/SoCal.gdb database. 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 Extent 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.ImportToolbox(r"C:\Program Files\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes\Production Mapping Tools.tbx") 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 the CompareLayerToSnapshot tool will select features that have been changed by extent, geometry or symbology. This example uses changes in symbology. 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 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 # Author: ESRI # Date: March 2010 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") # import the production mapping toolbox arcpy.ImportToolbox(r"C:\Program Files\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes\Production Mapping Tools.tbx") # 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")