ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

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

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

ArcMap

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

查找相同的

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

描述

报告要素类或表中在一系列字段中具有相同值的所有记录并生成一个列表文件以列出记录。如果选择了 Shape 字段,将会对要素几何进行比较。

删除相同的工具可用于查找并删除相同记录。

插图

Find Identical illustration
In this example, points with the OBJECTIDs of 1,2, 3, 8, 9, and 10 are spatially coincident (blue highlight). The output table identifies those spatially coincident points that share the same CATEGORY.

使用

  • 如果选定的输入字段值与这些记录值相同,则这些记录为相同记录。可对输入数据集中多个字段的值进行比较。如果指定了多个字段,则记录将首先按第一个字段中的值进行匹配,然后按第二个字段的值进行匹配,依此类推。

  • 对于要素类或要素图层输入,请选择字段参数中的 Shape 字段来比较要素几何,以按位置查找相同的要素。仅当“Shape”被选作其中一个输入字段时,XY 容差和 Z 容差参数才有效。

    如果选择了 Shape 字段并且输入要素的 M 值或 Z 值可用,则也可利用 M 值或 Z 值确定相同要素。

  • 如果在输出表中仅需要重复的记录,则选中仅输出重复记录参数。如果未选中此参数(默认),则输出的记录数与输入数据集的记录数相同。

  • 输出表含有两个字段:IN_FID 和 FEAT_SEQ。

    • IN_FID 字段可用于将输出表的记录连接到输入数据集。
    • 相同的记录具有相同的 FEAT_SEQ 值,而不相同的记录具有顺序值。FEAT_SEQ 值与输入记录的 ID 无关。

语法

FindIdentical(in_dataset, out_dataset, fields, {xy_tolerance}, {z_tolerance}, {output_record_option})
参数说明数据类型
in_dataset

要查找相同记录的表或要素类。

Table View
out_dataset

用于报告相同记录的输出表。在输出表中,相同记录的 FEAT_SEQ 字段具有相同值。

Table
fields
[fields,...]

将对字段值进行比较以查找相同记录的一个或多个字段。

Field
xy_tolerance
(可选)

在计算时应用于每个折点的 xy 容差(如果另一要素中存在相同的折点)。仅当 Shape 被选作其中一个输入字段时,此参数才可用。

Linear unit
z_tolerance
(可选)

在计算时应用于每个折点的 z 容差(如果另一要素中存在相同的折点)。仅当 Shape 被选作其中一个输入字段时,此参数才可用。

Double
output_record_option
(可选)

当仅需要在输出表中包含重复记录时选择。

  • ALL —所有输入记录在输出表中都有对应的记录。这是默认设置。
  • ONLY_DUPLICATES —仅重复记录在输出表中有对应的记录。无重复记录时输出为空。
Boolean

代码示例

FindIdentical 示例 1(Python 窗口)

以下 Python 窗口脚本演示了如何在即时模式下使用 FindIdentical 函数。

import arcpy

# Find identical records based on a text field and a numeric field.
arcpy.FindIdentical_management("C:/data/fireincidents.shp", "C:/output/duplicate_incidents.dbf", ["ZONE", "INTENSITY"])
FindIdentical 示例 2(独立脚本)

以下独立脚本演示了如何使用 FindIdentical 工具识别表或要素类的重复记录。

# Name: FindIdentical_Example2.py
# Description: Finds duplicate features in a dataset based on location (Shape field) and fire intensity

import arcpy

arcpy.env.overwriteOutput = True

# Set workspace environment
arcpy.env.workspace = "C:/data/findidentical.gdb"

# Set input feature class
in_dataset = "fireincidents"

# Set the fields upon which the matches are found
fields = ["Shape", "INTENSITY"]

# Set xy tolerance
xy_tol = ".02 Meters"

out_table = "duplicate_incidents"

# Execute Find Identical 
arcpy.FindIdentical_management(in_dataset, out_table, fields, xy_tol)
print(arcpy.GetMessages())
FindIdentical 示例 3:仅输出重复记录(独立脚本)

演示如何使用仅输出重复记录的可选参数。如果在工具对话框中选中或设置了 ONLY_DUPLICATES 值,则删除所有的唯一记录,仅保留输出中的重复记录。

# Name: FindIdentical_Example3.py
# Description: Demonstrates the use of the optional parameter Output only duplicated records.

import arcpy

arcpy.env.overwriteOutput = True

# Set workspace environment
arcpy.env.workspace = "C:/data/redlands.gdb"

in_data = "crime"
out_data = "crime_dups"

# Note that XY Tolerance and Z Tolerance parameters are not used
# In that case, any optional parameter after them must assign
# the value with the name of that parameter    
arcpy.FindIdentical_management(in_data, out_data, ["Shape"], output_record_option="ONLY_DUPLICATES")

print(arcpy.GetMessages())
FindIdentical 示例 4:利用 FEAT_SEQ 值将相同记录分组

读取 FindIdentical 工具的输出并利用 FEAT_SEQ 值将相同记录分组。

import arcpy

from itertools import groupby
from operator import itemgetter

# Set workspace environment
arcpy.env.workspace = r"C:\data\redlands.gdb"

# Run Find Identical on feature geometry only.
result = arcpy.FindIdentical_management("parcels", "parcels_dups", ["Shape"])
    
# List of all output records as IN_FID and FEAT_SEQ pair - a list of lists
out_records = []   
for row in arcpy.SearchCursor(result.getOutput(0), fields="IN_FID; FEAT_SEQ"):
    out_records.append([row.IN_FID, row.FEAT_SEQ])

# Sort the output records by FEAT_SEQ values
# Example of out_records = [[3, 1], [5, 3], [1, 1], [4, 3], [2, 2]]
out_records.sort(key = itemgetter(1))
    
# records after sorted by FEAT_SEQ: [[3, 1], [1, 1], [2, 2], [5, 3], [4, 3]]
# records with same FEAT_SEQ value will be in the same group (i.e., identical)
identicals_iter = groupby(out_records, itemgetter(1))
    
# now, make a list of identical groups - each group in a list.
# example identical groups: [[3, 1], [2], [5, 4]]
# i.e., IN_FID 3, 1 are identical, and 5, 4 are identical.
identical_groups = [[item[0] for item in data] for (key, data) in identicals_iter]

print(identical_groups)

环境

  • 当前工作空间
  • 临时工作空间
  • 范围
  • XY 容差
  • Z 容差

许可信息

  • Basic: 否
  • Standard: 否
  • Advanced: 是

相关主题

  • 常规工具集概述

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

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