<?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 Re: Insert missing features from one layer to another in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273291#M67294</link>
    <description>&lt;P&gt;I guess I mixed up append and merge. Append will append all feature in one layer to the other making duplicates, which is what I am trying to avoid.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Mar 2023 21:11:20 GMT</pubDate>
    <dc:creator>CCWeedcontrol</dc:creator>
    <dc:date>2023-03-29T21:11:20Z</dc:date>
    <item>
      <title>Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273286#M67292</link>
      <description>&lt;P&gt;I need to insert missing features from one layer to another. I don't want to use the append tool because I don't want a new dataset, I just want to insert the missing features. Both are polygons and have pretty much the same fields except for 3 fields ('Field1','Field2', 'Field3'). I have the following but I get no error when I run it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

fc1 = "lyTB" 
targetFC = "lyA_2"

dsc = arcpy.Describe(targetFC)
fields = dsc.fields
out_fields = [dsc.OIDFieldName, dsc.lengthFieldName, dsc.areaFieldName, 'Field1','Field2', 'Field3']
fieldnames = [field.name if field.name != 'Shape' else 'SHAPE@' for field in fields if field.name not in out_fields]

keepList = []
with arcpy.da.SearchCursor(fc1, fieldnames) as cursor:
    for row in cursor:
        keepList.append(row[0])
        #print(keepList)
del cursor

#list of values from fc1 to inject into targetFC
ids = []

with arcpy.da.SearchCursor(fc1, fieldnames) as cursor:
    for row in cursor:
        #print (row)
        if row[0] not in keepList:
            ids.append(row)
del cursor

#import all fields
#create insert cursor variable
with arcpy.da.InsertCursor(targetFC,fieldnames) as insCursor:
    for rows in ids:
        insertCursor.insertRow(rows)

print ('Done')&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 29 Mar 2023 21:00:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273286#M67292</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-03-29T21:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273288#M67293</link>
      <description>&lt;P&gt;Append doesn't create a new output featureclass... merge does&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/append.htm" target="_blank"&gt;Append (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 21:06:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273288#M67293</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-03-29T21:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273291#M67294</link>
      <description>&lt;P&gt;I guess I mixed up append and merge. Append will append all feature in one layer to the other making duplicates, which is what I am trying to avoid.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 21:11:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273291#M67294</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-03-29T21:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273292#M67295</link>
      <description>&lt;P&gt;Not if you have the records you want selected, and drag the layer into the Append dialog&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 21:12:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273292#M67295</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-03-29T21:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273295#M67296</link>
      <description>&lt;P&gt;It looks like you're checking fc1 twice with the search cursor.&lt;/P&gt;&lt;P&gt;The first round adds all of the objectIDs to the list, then the second round checks the same table to see if it's somehow missing the objectIDs you just added to it.&lt;/P&gt;&lt;P&gt;I'd check using something other than object ID if I were you, probably by checking the contents of the row, reason being that if one of the missing records is in the middle,&amp;nbsp; objectIDs will not match up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 21:15:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273295#M67296</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-03-29T21:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273303#M67297</link>
      <description>&lt;P&gt;I made the following changes.&lt;/P&gt;&lt;P&gt;line 24&amp;nbsp; was&lt;/P&gt;&lt;P&gt;if row[0] not in keepList:&lt;/P&gt;&lt;P&gt;should be;&lt;/P&gt;&lt;P&gt;if row not in keepList:&lt;/P&gt;&lt;P&gt;Line 32 was&lt;/P&gt;&lt;P&gt;InsertCursor .insertRow(rows)&lt;/P&gt;&lt;P&gt;Should have been&lt;/P&gt;&lt;P&gt;insCursor.insertRow(rows)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fc1 = "lyTB" 
targetFC = "lyA_2"

dsc = arcpy.Describe(targetFC)
fields = dsc.fields
out_fields = [dsc.OIDFieldName, dsc.lengthFieldName, dsc.areaFieldName, 'Field1','Field2', 'Field3']
fieldnames = [field.name if field.name != 'Shape' else 'SHAPE@' for field in fields if field.name not in out_fields]

keepList = []
with arcpy.da.SearchCursor(fc1, fieldnames) as cursor:
    for row in cursor:
        keepList.append(row[0])
        #print(keepList)
del cursor

#list of values from fc1 to inject into targetFC
ids = []

with arcpy.da.SearchCursor(fc1, fieldnames) as cursor:
    for row in cursor:
        #print (row)
        if row not in keepList:
            ids.append(row)
del cursor

#import all fields
#create insert cursor variable
with arcpy.da.InsertCursor(targetFC,fieldnames) as insCursor:
    for rows in ids:
        insCursor.insertRow(rows)

print ('Done')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I check using two other fields other than just the OID?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 21:36:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273303#M67297</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-03-29T21:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273532#M67304</link>
      <description>&lt;P&gt;So, first off, I owe you an apology. I made some assumptions about your code without fully understanding your fields variables or testing it myself. As it turns out, you weren't checking ObjectID at all.&lt;/P&gt;&lt;P&gt;In the code below, I've made keepList from the targetFC, and ids from the difference between it and fc1, checking by the entire row. Since those rows don't actually include ObjectID, if row[0] is, in fact, a unique field like a site number or something (and you &lt;U&gt;&lt;STRONG&gt;&lt;EM&gt;know&lt;/EM&gt; &lt;/STRONG&gt;&lt;/U&gt;it's unique), I think that'd be fine?&lt;/P&gt;&lt;P&gt;I only was able to test through the second search cursor, but the sum of keepList and ids came to the total of records in fc1, so I think this is at least a good start.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
mp = aprx.activeMap
fc1 = mp.listLayers()[0] # Copy in the Edit GDB, contains 25096 records
targetFC = mp.listLayers()[1] #Copy in the Published GDB, contains 11396 records

dsc = arcpy.Describe(targetFC)
fields = dsc.fields
out_fields = [dsc.OIDFieldName, dsc.lengthFieldName, dsc.areaFieldName, 'Field1','Field2', 'Field3']
fieldnames = [field.name if field.name != 'Shape' else 'SHAPE@' for field in fields if field.name not in out_fields]
#print(out_fields)
#print(fieldnames)

keepList = []
# Switched from fc1 to targetFC
# You want to check the final product first
with arcpy.da.SearchCursor(targetFC, fieldnames) as cursor:
    for row in cursor:
        keepList.append(row) #Appended row, not row[0]. 
                             #Otherwise they might not check for the same thing
del cursor

#list of values from fc1 to inject into targetFC
ids = []
#Check for missing values comparing by row in total.
with arcpy.da.SearchCursor(fc1, fieldnames) as cursor: 
    for row in cursor:
        if row not in keepList:
            ids.append(row)
del cursor

#import all fields
#create insert cursor variable
with arcpy.da.InsertCursor(targetFC,fieldnames) as insCursor:
    for rows in ids:
        insCursor.insertRow(rows)

print ('Done')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also maybe check out&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/feature-compare.htm" target="_blank"&gt;Feature Compare (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;and see if that's helpful?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 13:58:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273532#M67304</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-03-30T13:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273618#M67308</link>
      <description>&lt;P&gt;The current codes insert all the features in fc1 into the targetFc, at least for me. It doesn't appear to only insert the missing ones. If I run the code again, it just adds the total number of features in fc1again. I appreciate your input.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 16:10:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273618#M67308</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-03-30T16:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273671#M67309</link>
      <description>&lt;P&gt;I'm confused; I just tested it with no problems?&lt;/P&gt;&lt;P&gt;I have a my raw (target) table, which is purple and has 5196 records.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_1-1680195677972.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66806iA125806E9AF1A115/image-size/large?v=v2&amp;amp;px=999" role="button" title="AlfredBaldenweck_1-1680195677972.png" alt="AlfredBaldenweck_1-1680195677972.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;My edited table (fc1) is brown and has 5198 records. (&lt;EM&gt;I don't have these two records selected when I run the code)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_2-1680195721016.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66807iE73A8249C281A164/image-size/large?v=v2&amp;amp;px=999" role="button" title="AlfredBaldenweck_2-1680195721016.png" alt="AlfredBaldenweck_2-1680195721016.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Running the code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
mp = aprx.activeMap
fc1 = mp.listLayers("Edited")[0] # Copy in the Edit GDB, contains 25096 records
targetFC = mp.listLayers("Raw")[0] #Copy in the Published GDB, contains 11396 records

dsc = arcpy.Describe(targetFC)
fields = dsc.fields
out_fields = [dsc.OIDFieldName, dsc.lengthFieldName, dsc.areaFieldName, 'Field1','Field2', 'Field3']
fieldnames = [field.name if field.name != 'Shape' else 'SHAPE@' for field in fields if field.name not in out_fields]
#print(out_fields)
#print(fieldnames)

keepList = []
# Switched from fc1 to targetFC
# You want to check the final product first
with arcpy.da.SearchCursor(targetFC, fieldnames) as cursor:
    for row in cursor:
        keepList.append(row) #Appended row, not row[0]. 
                             #Otherwise they might not check for the same thing
print("Keeplist length: ", len(keepList))
del cursor

#list of values from fc1 to inject into targetFC
ids = []
#Check for missing values comparing by row in total.
with arcpy.da.SearchCursor(fc1, fieldnames) as cursor: 
    for row in cursor:
        if row not in keepList:
            ids.append(row)
print("ids: ", ids, len(ids))
del cursor

#import all fields
#create insert cursor variable
with arcpy.da.InsertCursor(targetFC,fieldnames) as insCursor:
    for rows in ids:
        insCursor.insertRow(rows)



print ('Done', arcpy.management.GetCount(targetFC))&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_4-1680195943510.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66810iC407AE1A0D71B992/image-size/large?v=v2&amp;amp;px=999" role="button" title="AlfredBaldenweck_4-1680195943510.png" alt="AlfredBaldenweck_4-1680195943510.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;My two new records are added to the target (ignore the OBJECTIDs; I've run this a few times already).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_3-1680195851638.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66808iB20A287FD20C6135/image-size/large?v=v2&amp;amp;px=999" role="button" title="AlfredBaldenweck_3-1680195851638.png" alt="AlfredBaldenweck_3-1680195851638.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 17:14:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273671#M67309</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-03-30T17:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273825#M67314</link>
      <description>&lt;P&gt;I was running this outside Pro and thought maybe that was why I was getting different results but no. I put the info in Pro and ran the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here are my results&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="BeforeRunningCode- ArcGIS Pro.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66860i2F5256635A59B77D/image-size/large?v=v2&amp;amp;px=999" role="button" title="BeforeRunningCode- ArcGIS Pro.png" alt="BeforeRunningCode- ArcGIS Pro.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AfterRunningCode- ArcGIS Pro.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66861i0CB3D9936851A3EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="AfterRunningCode- ArcGIS Pro.png" alt="AfterRunningCode- ArcGIS Pro.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought maybe I had something wrong in the code, so I copied the code you posted and ran it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
mp = aprx.activeMap
fc1 = mp.listLayers("Source")[0] # Copy in the Edit GDB, contains 25096 records
targetFC = mp.listLayers("target")[0] #Copy in the Published GDB, contains 11396 records

dsc = arcpy.Describe(targetFC)
fields = dsc.fields
out_fields = [dsc.OIDFieldName, dsc.lengthFieldName, dsc.areaFieldName, 'Field1','Field2', 'Field3']
fieldnames = [field.name if field.name != 'Shape' else 'SHAPE@' for field in fields if field.name not in out_fields]
#print(out_fields)
#print(fieldnames)

keepList = []
# Switched from fc1 to targetFC
# You want to check the final product first
with arcpy.da.SearchCursor(targetFC, fieldnames) as cursor:
    for row in cursor:
        keepList.append(row) #Appended row, not row[0]. 
                             #Otherwise they might not check for the same thing
print("Keeplist length: ", len(keepList))
del cursor

#list of values from fc1 to inject into targetFC
ids = []
#Check for missing values comparing by row in total.
with arcpy.da.SearchCursor(fc1, fieldnames) as cursor: 
    for row in cursor:
        if row not in keepList:
            ids.append(row)
print("ids: ", ids, len(ids))
del cursor

#import all fields
#create insert cursor variable
with arcpy.da.InsertCursor(targetFC,fieldnames) as insCursor:
    for rows in ids:
        insCursor.insertRow(rows)



print ('Done', arcpy.management.GetCount(targetFC))&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 30 Mar 2023 20:28:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273825#M67314</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-03-30T20:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273828#M67315</link>
      <description>&lt;P&gt;What happens if you remove GlobalID from the list of fields? Necessarily, it won't be the same between each copy.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 20:33:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1273828#M67315</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-03-30T20:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1274128#M67320</link>
      <description>&lt;P&gt;I wasn't sure if you meant, if in the script or the layers, I removed the GlobalID from both feature classes and I am still getting doubles. Would you like me to share some of the data?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2023-03-31 09_21_07-Window.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/66945iD479222F33A2486E/image-size/large?v=v2&amp;amp;px=999" role="button" title="2023-03-31 09_21_07-Window.png" alt="2023-03-31 09_21_07-Window.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 15:23:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1274128#M67320</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-03-31T15:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1274329#M67323</link>
      <description>&lt;P&gt;I meant in the script, placing it in out_fields&lt;/P&gt;&lt;P&gt;Sure, if you can share a few records (in a gdb of some sort), I'd be happy to take a look at it.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2023 23:21:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1274329#M67323</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-03-31T23:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1274800#M67329</link>
      <description>&lt;P&gt;I have these in a file geodatabase, and I removed all the none important fields.&lt;/P&gt;&lt;P&gt;Thanks I really appreciate your help.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 17:08:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1274800#M67329</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-04-03T17:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1274878#M67330</link>
      <description>&lt;P&gt;So, I took a look at your data, and I think I've found the problem?&lt;/P&gt;&lt;P&gt;1) Placing "GlobalID" into the out_fields immediately helped and cut back the number of records added.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) You have a few issues in your data that were causing the rows to be separate:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Not all of the records in your target feature class have geometry (89 records)&lt;BR /&gt;This causes row[0] to be None, rather than a polygon object, making the two tables mismatch.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_2-1680545748028.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67103iA9C1C04FF60F2E01/image-size/large?v=v2&amp;amp;px=999" role="button" title="AlfredBaldenweck_2-1680545748028.png" alt="AlfredBaldenweck_2-1680545748028.png" /&gt;&lt;/span&gt;&lt;/LI&gt;&lt;LI&gt;You have some mismatched acreages between the two tables (There are 35 of these where their shapes are the same.)&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_1-1680545677862.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67102i3163B9455F4FB186/image-size/large?v=v2&amp;amp;px=999" role="button" title="AlfredBaldenweck_1-1680545677862.png" alt="AlfredBaldenweck_1-1680545677862.png" /&gt;&lt;/span&gt;&lt;/LI&gt;&lt;LI&gt;Not sure if there's a difference in Parcel#, but there could be&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Code below to tell you which ones have problems.&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
mp = aprx.activeMap
fc1 = mp.listLayers("sourceFC")[0] # Copy in the Edit GDB, contains 25096 records
targetFC = mp.listLayers("targetFC")[0] #Copy in the Published GDB, contains 11396 records

dsc = arcpy.Describe(targetFC)
fields = dsc.fields

out_fields = ["FID", "Shape_Leng", "Shape_Area", "Duplicate", "GlobalID"]
fieldnames = [field.name if field.name != 'Shape'  else 'SHAPE@' for field in fields if field.name not in out_fields]

print(out_fields)
print(fieldnames)

keepList = []
# Switched from fc1 to targetFC
# You want to check the final product first
with arcpy.da.SearchCursor(targetFC, fieldnames, sql_clause = (None, "ORDER BY PermitNum")) as cursor:
    for row in cursor:
        if row[0] is None:
            print(row)
            keepList.append(row) #Appended row, not row[0]. 
                             #Otherwise they might not check for the same thing
        #print(row)
del cursor
#print(keepList)

print(len(keepList))
print("Break \n\n")

#list of values from fc1 to inject into targetFC
ids = []
#Check for missing values comparing by row in total.
with arcpy.da.SearchCursor(fc1, fieldnames, sql_clause = (None, "ORDER BY PermitNum")) as cursor: 
    for row in cursor:
        for k in keepList:
            if row[0] == k[0]:
                if row[3] != k[3]:
                    print(row, k)
        #if row[1] not in keepList:
                    ids.append(row)
            #print(row)
del cursor

print(len(ids))&lt;/LI-CODE&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 18:37:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1274878#M67330</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-04-03T18:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1275013#M67332</link>
      <description>&lt;P&gt;Oh wow. I looked back at my original data and there no empty geometry. I think I might have shared one (targetFC),that must have corrupted after testing, my apologies.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached a copy of the original data(targetFC), with the unnecessary fields removed. I verified there were no empty geometry, again my apologies.&lt;/P&gt;&lt;P&gt;After verifying that both dataset had no empty geometry and verified with the code you attached.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;0
Break 
0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran the code below, but it created empty geometry on the target feature class. It appears to that the empty geometry ones are the missing ones that are being inserted into the targetFC.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;dsc = arcpy.Describe(targetFC)
fields = dsc.fields
out_fields = ['OID@', 'Shape_Leng', 'Shape_Area', 'Duplicate', 'GlobalID']
fieldnames = [field.name if field.name != 'Shape' else 'SHAPE@' for field in fields if field.name not in out_fields]
#print(out_fields)
#print(fieldnames)

keepList = []
# Switched from fc1 to targetFC
# You want to check the final product first
with arcpy.da.SearchCursor(targetFC, fieldnames) as cursor:
    for row in cursor:
        keepList.append(row) #Appended row, not row[0]. 
                             #Otherwise they might not check for the same thing
print("Keeplist length: ", len(keepList))
del cursor

#list of values from fc1 to inject into targetFC
ids = []
#Check for missing values comparing by row in total.
with arcpy.da.SearchCursor(fc1, fieldnames) as cursor: 
    for row in cursor:
        if row not in keepList:
            ids.append(row)
print("ids: ", ids, len(ids))
del cursor

#import all fields
#create insert cursor variable
with arcpy.da.InsertCursor(targetFC,fieldnames) as insCursor:
    for rows in ids:
        insCursor.insertRow(rows)



print ('Done', arcpy.management.GetCount(targetFC))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 21:49:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1275013#M67332</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-04-03T21:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1275026#M67333</link>
      <description>&lt;P&gt;I was able to solve the empty geometry, by adding ['Shape@'] in the field names. I also included the sql_clause you had.&lt;/P&gt;&lt;P&gt;Based on I am seeing and the print out, the script is just adding all the features from sourcFC and not acutally comparing and inserting the missing ones.&lt;/P&gt;&lt;P&gt;Would it be best to compare two or three fields, if so how?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;dsc = arcpy.Describe(targetFC)
fields = dsc.fields
out_fields = ['OID@',  'Duplicate', 'GlobalID']
fieldnames = [field.name if field.name != 'Shape' else 'SHAPE@' for field in fields if field.name not in out_fields]
#print(out_fields)
#print(fieldnames)

keepList = []
# Switched from fc1 to targetFC
# You want to check the final product first
with arcpy.da.SearchCursor(targetFC, ['SHAPE@'] + fieldnames, sql_clause = (None, "ORDER BY PermitNum")) as cursor:
    for row in cursor:
        keepList.append(row) #Appended row, not row[0]. 
                             #Otherwise they might not check for the same thing
print("Keeplist length: ", len(keepList))
del cursor

#list of values from fc1 to inject into targetFC
ids = []
#Check for missing values comparing by row in total.
with arcpy.da.SearchCursor(fc1, ['SHAPE@'] + fieldnames, sql_clause = (None, "ORDER BY PermitNum")) as cursor: 
    for row in cursor:
        if row not in keepList:
            ids.append(row)
print("ids: ", ids, len(ids))
del cursor

#import all fields
#create insert cursor variable
with arcpy.da.InsertCursor(targetFC, ['SHAPE@'] + fieldnames) as insCursor:
    for rows in ids:
        insCursor.insertRow(rows)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 22:24:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1275026#M67333</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-04-03T22:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1277019#M67389</link>
      <description>&lt;P&gt;Sorry for the delay in getting back to you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Don't bother to add SHAPE@ to the fields list like that; it's already the first entry in the fieldslist.&lt;/P&gt;&lt;P&gt;Unfortunately, I don't really have a good answer for you.&lt;/P&gt;&lt;P&gt;If it works for you, your original approach of just comparing shape will work fine. You can do this either with a cursor, or select by location where they're identical and invert the spatial relationship. (There is a difference of one record between comparing via cursor and select by location. I'm not sure which one it is, and I'm not sure why).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I don't know your data as well as you do, so it isn't clear to me what differences are acceptable. It might be most time-efficient to add the missing records based on shape and then manually reviewing (FindIndentical is a lifesaver)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 18:12:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1277019#M67389</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-04-10T18:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Insert missing features from one layer to another</title>
      <link>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1277490#M67398</link>
      <description>&lt;P&gt;No worries, I really appreciate you trying to help.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2023 19:07:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/insert-missing-features-from-one-layer-to-another/m-p/1277490#M67398</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2023-04-11T19:07:27Z</dc:date>
    </item>
  </channel>
</rss>

