ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

Compare Layer to Snapshot

  • 描述
  • 使用方法
  • 语法
  • 代码示例
  • 环境
  • 许可信息

描述

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

使用方法

  • 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.

语法

arcpy.production.CompareLayerToSnapshot(in_features, snapshot_field_name, invert_selection)
参数说明数据类型
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.

String
invert_selection

Specifies if the tool should select changed features or invert the selection to unchanged features.

  • SELECT_UNCHANGED —Select only features whose geometries, extents, and symbols have not changed.
  • SELECT_CHANGED —Select only features whose geometries, extents, and symbols have changed. This is the default.
Boolean

代码示例

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 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: ArcGIS 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()

环境

  • 当前工作空间

许可信息

  • Basic: 否
  • Standard: 需要 Production Mapping
  • Advanced: 需要 Production Mapping

相关主题

  • An overview of the Layer Snapshot toolset

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2021 Esri. | 隐私政策 | 法律声明