<?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: script for removing apend duplicats returing unexpected results in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1308401#M68171</link>
    <description>&lt;P&gt;Not sure if it's case sensitive, but the docs for the&amp;nbsp;ston shows all ca&lt;SPAN class=""&gt;TRUECENTROID&lt;/SPAN&gt;.&amp;nbsp; Might try that caps case and if it still doesn't, work as expected, I'd approach it differently using Shape@ and shpe_desc = arcpy.Desccribe(row[2]) to access the details.&lt;/P&gt;&lt;P&gt;The screenshots are from the debugger in Pycharm.&amp;nbsp; Not sure which IDE you are using, but there are tutorials out there for setting up stepping through code. Run a web search for &amp;lt;your ide&amp;gt; debugging python' and you'll get something to point you to the right direction.&lt;/P&gt;</description>
    <pubDate>Sat, 15 Jul 2023 00:35:27 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2023-07-15T00:35:27Z</dc:date>
    <item>
      <title>script for removing apend duplicats returing unexpected results</title>
      <link>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1306939#M68124</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am cleaning up a curbed streets feature class. The fc was appended to as sections were completed. I modified the remove duplicate appends script. It ran successfully without error. The script is….&lt;/SPAN&gt;&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;import arcpy

fc = r"N:\laura\edit_map4\edit_map4.gdb\StormCurbedStr_ExportFeature2"
feilds = ["FULLNAME","curb","SHAPE"]
keepList = list()

with arcpy.da.UpdateCursor(fc, feilds) as cursor:

    for row in cursor:
        row_val = row[0] + row[1] + str(row[2])
    
        if row_val not in keepList:
            keepList.append(row_val)

        elif row_val in keepList:
            cursor.deleteRow()
    
        else:
            pass
print("done")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The results are being looked over to verify it functioned as expected. Several features were deleted, as expected. The find identical tool was run on the resulting features to verify further. The same three fields were used as parameters and were in the exact order as in the original remove duplicate appends script. Also, the output duplicates-only box was checked. The find identical tool found 66 duplicates in pairs. I am investigating why the script did not find these. After checking both the FULLNAME and curb fields, they were identical in each of the 33 pairs. I.e., no leading or trailing spaces, misspellings, or even discrepant capitalization. I ruled these 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;fields out. The select-by-location tool was used to check the geometry. Both the input feature and the selecting features were the curbed streets feature class, and the relationship was&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;&lt;SPAN&gt;are identical to.&amp;nbsp;&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN&gt;All 66 features returned. To see how the script dealt with the shape parameter, I ran a script to see what it used for the shape parameter values. The script is…&lt;/SPAN&gt;&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;fc = r"N:\laura\edit_map4\edit_map4.gdb\StormCurbedStr_invegstate_3"
feilds = ["FULLNAME","curb","SHAPE"]
 
with arcpy.da.UpdateCursor(fc, feilds) as cursor:

    for row in cursor:
        print(str(row[2]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It returned some weird results. First, it gave me a list of coordinate points even though it is a line feature. I copied the output and pasted it into Excel to highlight the duplicates. No duplicates were flagged. It seems like the script pulled different points along these lines in each instance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It boils down to 3 things.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Why is the script returning coordinates when it is a line feature?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How/what is the update cursor object using to satisfy the shape field?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How do I amend the remove duplicate appends script to get all the duplicates?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 14:05:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1306939#M68124</guid>
      <dc:creator>Laura_m_Conner</dc:creator>
      <dc:date>2023-07-10T14:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: script for removing apend duplicats returing unexpected results</title>
      <link>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1307865#M68152</link>
      <description>&lt;P&gt;If you study the help file on the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/searchcursor-class.htm" target="_self"&gt;searchcursor&lt;/A&gt;, look at the syntax section, all the inputs have a&amp;nbsp;@ character, so if you want to return a geometry object you need to set the field name to be &lt;A href="mailto:shape@," target="_blank"&gt;shape@,&lt;/A&gt;&amp;nbsp;you are using &lt;EM&gt;shape&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;I would suggest you explore the use of the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/find-identical.htm" target="_self"&gt;Find Identical&lt;/A&gt; tool and &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/delete-identical.htm" target="_self"&gt;Delete Identical&lt;/A&gt;&amp;nbsp;tools to simplify your code, you don't need to be using cursors for this task.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 10:32:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1307865#M68152</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2023-07-13T10:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: script for removing apend duplicats returing unexpected results</title>
      <link>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1308009#M68163</link>
      <description>&lt;P&gt;changing&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;feilds = ["FULLNAME","curb","SHAPE"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;to&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;feilds = ["FULLNAME","curb","SHAPE@"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;did not work. It deleted the both features in the duplicate pair.&amp;nbsp; Also it deleted several features that were not in a duplicate pair.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/delete-identical.htm" target="_self" rel="nofollow noopener noreferrer"&gt;Delete Identical&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;tool did remove the duplicates&amp;nbsp;without&amp;nbsp; removing both features.&amp;nbsp; However I am trying to under stand why the my script acted as it did. the more I&amp;nbsp;understand now the better&amp;nbsp;I&amp;nbsp;be at trouble shouting&amp;nbsp;in the future.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 17:53:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1308009#M68163</guid>
      <dc:creator>Laura_m_Conner</dc:creator>
      <dc:date>2023-07-13T17:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: script for removing apend duplicats returing unexpected results</title>
      <link>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1308126#M68165</link>
      <description>&lt;P&gt;You are pointed to a different dataset for the test part up there- is that why you are seeing different list of coordinates from the dataset that you are using in the first script?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Why is the script returning coordinates when it is a line feature?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Shape returns just a coordinate (details/theory below). You can see the JSON and WKT properties of the geometry object is just an array of points at its core.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeffK_5-1689302658557.png" style="width: 599px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75388iC9F52A4E5C075258/image-dimensions/599x45?v=v2" width="599" height="45" role="button" title="JeffK_5-1689302658557.png" alt="JeffK_5-1689302658557.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;How/what is the update cursor object using to satisfy the shape field?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;When you are using Shape, it returns a point calculated from something. I couldn't match the tuple coord to anything in my example that I tested on... Shape@ returns the complete described geometry object.&lt;/P&gt;&lt;P&gt;When you use the @, you are accessing the geometry object so when you cast it to string, you are getting the string value '&amp;lt;geoprocessing describe geometry object object at xXxx&amp;gt;'. Since memory is recycled, this could be causing false positives for duplicates and deleting the row because xXxxx is a place in memory and it will always contain the '&lt;EM&gt;geoprocessing describe geometry object object at' part&lt;/EM&gt;. For example, when looking at it in the debugger your row_val is:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeffK_0-1689301387380.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75383iC3B7A5229AA07C3C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeffK_0-1689301387380.png" alt="JeffK_0-1689301387380.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If you look at the Shape@ at row[2] in the debugger, you can see its object properties:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeffK_4-1689301750164.png" style="width: 545px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75387iAF6BC3CE0B2563AD/image-dimensions/545x284?v=v2" width="545" height="284" role="button" title="JeffK_4-1689301750164.png" alt="JeffK_4-1689301750164.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Going back to using Shape, that row[2] tuple is nowhere in the SHAPE@ properties.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JeffK_3-1689301582911.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75386i23EBD1EEF62884E0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JeffK_3-1689301582911.png" alt="JeffK_3-1689301582911.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It would be interesting to see where that coordinate plots to along the line...&lt;/P&gt;&lt;P&gt;&lt;EM&gt;How do I amend the remove duplicate appends script to get all the duplicates?&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;If you wanted to continue with the script, access the Shape@ geometry properties and such as firstPoint, lastPoint, trueCentroid and use those for comparison.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 02:47:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1308126#M68165</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-07-14T02:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: script for removing apend duplicats returing unexpected results</title>
      <link>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1308332#M68169</link>
      <description>&lt;P&gt;thank you that was truly good information. I understand the script and the general way Esri deals with geometry. This answers most of my questions however...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried amending the script&amp;nbsp; to&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;feilds = ["FULLNAME","curb","SHAPE@trueCentroid"]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The script ran and did not delete any false positives, however it&amp;nbsp; left&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;66 duplicates in pairs. likely&amp;nbsp;the same ones as before. Still don't&amp;nbsp;know why.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;PS. how do you get to the window you took screen shots of for the debugging?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 19:57:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1308332#M68169</guid>
      <dc:creator>Laura_m_Conner</dc:creator>
      <dc:date>2023-07-14T19:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: script for removing apend duplicats returing unexpected results</title>
      <link>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1308401#M68171</link>
      <description>&lt;P&gt;Not sure if it's case sensitive, but the docs for the&amp;nbsp;ston shows all ca&lt;SPAN class=""&gt;TRUECENTROID&lt;/SPAN&gt;.&amp;nbsp; Might try that caps case and if it still doesn't, work as expected, I'd approach it differently using Shape@ and shpe_desc = arcpy.Desccribe(row[2]) to access the details.&lt;/P&gt;&lt;P&gt;The screenshots are from the debugger in Pycharm.&amp;nbsp; Not sure which IDE you are using, but there are tutorials out there for setting up stepping through code. Run a web search for &amp;lt;your ide&amp;gt; debugging python' and you'll get something to point you to the right direction.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2023 00:35:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-for-removing-apend-duplicats-returing/m-p/1308401#M68171</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-07-15T00:35:27Z</dc:date>
    </item>
  </channel>
</rss>

