<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Script for Find Identical tool in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/script-for-find-identical-tool/m-p/1241001#M63405</link>
    <description>&lt;P&gt;I want to write a script that will find duplicate polygons based on shape, defined attribute, and location.&amp;nbsp; I think that the Find Identical tool will provide what I need, but I do not have the license to use it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 14 Dec 2022 11:07:40 GMT</pubDate>
    <dc:creator>CFrost</dc:creator>
    <dc:date>2022-12-14T11:07:40Z</dc:date>
    <item>
      <title>Script for Find Identical tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/script-for-find-identical-tool/m-p/1241001#M63405</link>
      <description>&lt;P&gt;I want to write a script that will find duplicate polygons based on shape, defined attribute, and location.&amp;nbsp; I think that the Find Identical tool will provide what I need, but I do not have the license to use it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 11:07:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/script-for-find-identical-tool/m-p/1241001#M63405</guid>
      <dc:creator>CFrost</dc:creator>
      <dc:date>2022-12-14T11:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Script for Find Identical tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/script-for-find-identical-tool/m-p/1241011#M63409</link>
      <description>&lt;LI-CODE lang="python"&gt;# input parameters
in_table = "path_or_layer_name"
out_table_folder = "memory"
out_table_name = "identical"
fields = ["IntegerField", "Shape"]
only_duplicate = False


# create output table
out_table = arcpy.management.CreateTable(out_table_folder, out_table_name)
arcpy.management.AddField(out_table, "IN_FID", "LONG")
arcpy.management.AddField(out_table, "FEAT_SEQ", "LONG")

# read and group in_table
groups = dict()
for i, f in enumerate(fields):
    if f == "Shape":
        fields[i] = "SHAPE@WKT"
with arcpy.da.SearchCursor(in_table, ["OID@"] + fields) as cursor:
    for row in cursor:
        oid = row[0]
        key = tuple(row[1:])
        try:
            groups[key].append(oid)
        except KeyError:
            groups[key] = [oid]

# write groups into out_table
with arcpy.da.InsertCursor(out_table, ["IN_FID", "FEAT_SEQ"]) as cursor:
    for seq, key in enumerate(groups.keys()):
        oids = groups[key]
        if only_duplicate and len(oids) &amp;lt; 2:
            continue
        for oid in oids:
            cursor.insertRow([oid, seq])&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 14 Dec 2022 12:28:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/script-for-find-identical-tool/m-p/1241011#M63409</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-12-14T12:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Script for Find Identical tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/script-for-find-identical-tool/m-p/1241506#M63457</link>
      <description>&lt;P&gt;Hi, thanks for this, much appreciated!&amp;nbsp; Ive amended the above code to look at shape_length and shape_area as a test but am receiving the following error message&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 21, in &amp;lt;module&amp;gt;&lt;BR /&gt;RuntimeError: Request canceled&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My amended code is as follows:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# input parameters
in_table = "temp_layer"
out_table_folder = "memory"
out_table_name = "identical"
fields = ["Shape_length", "SHAPE_Area"]
only_duplicate = False


# create output table
arcpy.env.overwriteOutput = True 
out_table = arcpy.management.CreateTable(out_table_folder, out_table_name)
arcpy.management.AddField(out_table, "IN_FID", "LONG")
arcpy.management.AddField(out_table, "FEAT_SEQ", "LONG")

# read and group in_table
groups = dict()
for i, f in enumerate(fields):
    if f == "Shape":
        fields[i] = "SHAPE@WKT"
with arcpy.da.SearchCursor(in_table, ["OID@"] + fields) as cursor:
    for row in cursor:
        oid = row[0]
        key = tuple(row[1:])
        try:
            groups[key].append(oid)
        except KeyError:
            groups[key] = [oid]

# write groups into out_table
with arcpy.da.InsertCursor(out_table, ["IN_FID", "FEAT_SEQ"]) as cursor:
    for seq, key in enumerate(groups.keys()):
        oids = groups[key]
        if only_duplicate and len(oids) &amp;lt; 2:
            continue
        for oid in oids:
            cursor.insertRow([oid, seq])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any suggestions?&amp;nbsp; Also, I would like to compare string fields in addition to integer fields - will this code work regardless of the field type?&amp;nbsp; Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 12:23:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/script-for-find-identical-tool/m-p/1241506#M63457</guid>
      <dc:creator>CFrost</dc:creator>
      <dc:date>2022-12-15T12:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Script for Find Identical tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/script-for-find-identical-tool/m-p/1241521#M63461</link>
      <description>&lt;P&gt;Hmm... "Request canceled" is an error I have never seen before, and I can't find it online, either. There is always the tried and true "restart ArcGIS", but other than that I have no idea.&lt;/P&gt;&lt;P&gt;While checking Shape_Length and Shape_Area should work ( I could do it when testing), maybe start with a simple test table.&lt;/P&gt;&lt;P&gt;Yes, you should be able to find identical Strings, Integers, Doubles (excluding rounding errors), Dates, and Geometries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good catch with overwriteOutput. That defaults to True in my setup, so I didn't think about that.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 13:34:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/script-for-find-identical-tool/m-p/1241521#M63461</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-12-15T13:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Script for Find Identical tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/script-for-find-identical-tool/m-p/1241525#M63463</link>
      <description>&lt;P&gt;Thanks for the response, knowing that its an error you aren't familiar with is helpful to know - Ill try the usual things as you suggest.&amp;nbsp; Thanks for the help, really appreciate it!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update - managed to resolve the error (not sure how).&amp;nbsp; The output looks like this:&lt;/P&gt;&lt;P&gt;OBJECTID IN_FID FEAT_SEQ&lt;BR /&gt;1 1 0&lt;BR /&gt;2 2 1&lt;BR /&gt;3 3 2&lt;BR /&gt;4 4 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that OID 1 and OID 4 are completely identical (test dataset to see how the output would work), but its not clear to me how the output is showing this - would you mind explaining?&amp;nbsp; Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update:&amp;nbsp; Ive managed to resolve the issues of the output by changing 'only_duplicate= true'&amp;nbsp; This generates an output similar to the Overlapping Features tool where it lists the feature IDs that are duplicated.&amp;nbsp; Oddly, when I changed it back to 'false' the Feat_seq field shows duplicate values where the feature is duplicated so looks like it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this solution - very useful!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Dec 2022 11:39:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/script-for-find-identical-tool/m-p/1241525#M63463</guid>
      <dc:creator>CFrost</dc:creator>
      <dc:date>2022-12-16T11:39:03Z</dc:date>
    </item>
  </channel>
</rss>

