Compare Layer to Snapshot (Production Mapping)

Niveau de licence :BasicStandardAdvanced

Récapitulatif

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

Utilisation

Syntaxe

CompareLayerToSnapshot_production (in_features, snapshot_field_name, invert_selection)
ParamètreExplicationType de données
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

Exemple de code

CompareLayerToSnapshot example (Python window)

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

import arcpy

# Run the Calculate Layer Snapshot tool on this data using a 'snapshot' field before running this script.
# set gp environment
arcpy.env.workspace = "C:/data/Austin.gdb"
arcpy.env.addOutputsToMap = True
arcpy.env.overwriteOutput = True

#local variables
railroad="RailRoadL"
railLayer = "railLayer"
snapshotField="snapshot"
invertSelection="SELECT_UNCHANGED"

# check for a snapshot field
field_names = [f.name for f in arcpy.ListFields(railroad,snapshotField,"LONG")]
if field_names.count(snapshotField) < 1:
    print "Missing snapshot field - run CalculateLayerSnapshot first"
else:
    # create a feature layer from railroad
    arcpy.MakeFeatureLayer_management(railroad, railLayer)

    # execute the Compare Layer To Snapshot tool
    arcpy.CompareLayerToSnapshot_production(railLayer,snapshotField,invertSelection)

    # get a count of selected features
    desc = arcpy.Describe(railLayer)
    selectedFids = desc.FIDSet

    # write selected features to a new feature class
    if len(selectedFids) > 0:
	   arcpy.CopyFeatures_management(railLayer,"in_memory/unchangedfeatures")
CompareLayerToSnapshot example 2 (Stand–alone Python script)

The following stand-alone Python script demonstrates how to use the CompareLayerToSnapshot tool.

# Name: CompareLayerToSnapshot_Example.py
# Description: Uses Production Mapping Layer Snapshot functionality to
#  find and writes changed features (in this example - symbols) to a new feature class
# Requirements: Esri Production Mapping

import arcpy, sys

# check out a foundation license
arcpy.CheckOutExtension("Foundation")

# set the current workspace
arcpy.env.workspace = "C:/data/Austin.gdb"
arcpy.env.overwriteOutput = True

# local variables
railroad = "RailroadL"
railLayer = "railLayer"
snapshotField="snapshot"
invertSel = "SELECT_CHANGED"

# make a feature layer from the RailRoadL feature class
arcpy.MakeFeatureLayer_management(railroad,railLayer)

# check for a snapshot field
field_names = [f.name for f in arcpy.ListFields(railroad,snapshotField,"LONG")]
if field_names.count(snapshotField) < 1:
    print "Missing snapshot field - run CalculateLayerSnapshot first"
    sys.exit(0)

# check for changed features in the snapshot field
arcpy.CompareLayerToSnapshot_production(railLayer,snapshotField,invertSel)
print arcpy.GetMessages()

# describe the feature layer to access the the selected set
desc = arcpy.Describe(railLayer)

# FIDSet will contain the selected features
selectedFids = desc.FIDSet

# 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(railLayer,"changedfeatures")
	print arcpy.GetMessages()

Environnements

Thèmes connexes

Informations de licence

ArcGIS for Desktop Basic: Annuler
ArcGIS for Desktop Standard: Requis Production Mapping
ArcGIS for Desktop Advanced: Requis Production Mapping
4/26/2014