<?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: Why is this code deleting rows within a feature class? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1273773#M67312</link>
    <description>&lt;P&gt;That part actually works fine for me, I get an error without the '_US'&lt;/P&gt;</description>
    <pubDate>Thu, 30 Mar 2023 19:20:18 GMT</pubDate>
    <dc:creator>ccowin_odfw</dc:creator>
    <dc:date>2023-03-30T19:20:18Z</dc:date>
    <item>
      <title>Why is this code deleting rows within a feature class?</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1271132#M67200</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;My organization has a couple administrative boundaries that are used for modeling and I'm trying to split them against each other and then figure out the percentage of state, federal, tribal and private land is for each of the subsections.&lt;BR /&gt;&lt;BR /&gt;I wrote the following code it splits one feature by the other that contains ownership data. When I then go to process each output of the split it just completely deletes all the rows in some of the features and I have no idea why or how that can even happen.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;arcpy&lt;BR /&gt;&lt;BR /&gt;gdb &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;path redacted&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;if &lt;/SPAN&gt;arcpy.&lt;SPAN&gt;Exists&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;gdb&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.&lt;SPAN&gt;Delete_management&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;gdb&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;arcpy.management.&lt;SPAN&gt;CreateFileGDB&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;path redacted&amp;gt;&lt;/SPAN&gt;, &lt;SPAN&gt;'DAU_by_Ownership.gdb'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;all_wmus &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;path redacted&amp;gt;&lt;BR /&gt;&lt;/SPAN&gt;jurisdiction &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;path redacted&amp;gt;&lt;BR /&gt;&lt;/SPAN&gt;split &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;path redacted&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;arcpy.analysis.&lt;SPAN&gt;Split&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;jurisdiction, all_wmus, &lt;SPAN&gt;'UNIT_NAME'&lt;/SPAN&gt;, gdb&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;arcpy.env.workspace &lt;SPAN&gt;= &lt;/SPAN&gt;gdb&lt;BR /&gt;WMUs &lt;SPAN&gt;= &lt;/SPAN&gt;arcpy.&lt;SPAN&gt;ListFeatureClasses&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;get_acres&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;features&lt;/SPAN&gt;, &lt;SPAN&gt;field&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;BR /&gt;&lt;/SPAN&gt;    acres &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;with &lt;/SPAN&gt;arcpy.da.&lt;SPAN&gt;SearchCursor&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;features&lt;/SPAN&gt;, &lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;field&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;as &lt;/SPAN&gt;cursor&lt;SPAN&gt;:&lt;BR /&gt;&lt;/SPAN&gt;        &lt;SPAN&gt;for &lt;/SPAN&gt;row &lt;SPAN&gt;in &lt;/SPAN&gt;cursor&lt;SPAN&gt;:&lt;BR /&gt;&lt;/SPAN&gt;            acres &lt;SPAN&gt;= &lt;/SPAN&gt;row&lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;] &lt;/SPAN&gt;&lt;SPAN&gt;+ &lt;/SPAN&gt;acres&lt;BR /&gt;&lt;BR /&gt;    &lt;SPAN&gt;return &lt;/SPAN&gt;acres&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for &lt;/SPAN&gt;WMU &lt;SPAN&gt;in &lt;/SPAN&gt;WMUs&lt;SPAN&gt;:&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;# Calculate Area and Put that&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Getting area for ' &lt;/SPAN&gt;&lt;SPAN&gt;+ &lt;/SPAN&gt;WMU&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.management.&lt;SPAN&gt;CalculateGeometryAttributes&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;WMU, &lt;SPAN&gt;[[&lt;/SPAN&gt;&lt;SPAN&gt;'Acres'&lt;/SPAN&gt;, &lt;SPAN&gt;'AREA_GEODESIC'&lt;/SPAN&gt;&lt;SPAN&gt;]]&lt;/SPAN&gt;, &lt;SPAN&gt;area_unit&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;'ACRES_US'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;    wmu_acres &lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;get_acres&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;WMU, &lt;SPAN&gt;'ACRES'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;f'...&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;wmu_acres&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt; Acres'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.management.&lt;SPAN&gt;AddField&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;WMU, &lt;SPAN&gt;'WMU_Acres'&lt;/SPAN&gt;, &lt;SPAN&gt;'LONG'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.management.&lt;SPAN&gt;AddField&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;WMU, &lt;SPAN&gt;'DAU_Acres'&lt;/SPAN&gt;, &lt;SPAN&gt;'LONG'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.management.&lt;SPAN&gt;AddField&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;WMU, &lt;SPAN&gt;'WMU_pct'&lt;/SPAN&gt;, &lt;SPAN&gt;'FLOAT'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.management.&lt;SPAN&gt;AddField&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;WMU, &lt;SPAN&gt;'DAU_pct'&lt;/SPAN&gt;, &lt;SPAN&gt;'FLOAT'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.management.&lt;SPAN&gt;CalculateField&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;WMU, &lt;SPAN&gt;'UNIT_NAME'&lt;/SPAN&gt;, &lt;SPAN&gt;f'"&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;WMU&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;"'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.management.&lt;SPAN&gt;CalculateField&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;WMU, &lt;SPAN&gt;'WMU_Acres'&lt;/SPAN&gt;, &lt;SPAN&gt;f'&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;wmu_acres&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.management.&lt;SPAN&gt;CalculateField&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;WMU, &lt;SPAN&gt;'WMU_pct'&lt;/SPAN&gt;, &lt;SPAN&gt;f'!Acres! / !WMU_Acres!'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 23 Mar 2023 20:19:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1271132#M67200</guid>
      <dc:creator>ccowin_odfw</dc:creator>
      <dc:date>2023-03-23T20:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code deleting rows within a feature class?</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1271176#M67201</link>
      <description>&lt;P&gt;from&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/analysis/split.htm" target="_blank"&gt;Split (Analysis)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;are all the inputs overlapped by the splitting polygon?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 21:35:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1271176#M67201</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-03-23T21:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code deleting rows within a feature class?</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1271189#M67202</link>
      <description>&lt;P&gt;No, there is no documentation saying they need to be. If nothing is under the split feature then no output feature should be generated at all. The damage to the feature class is coming later, I just split them from code fine but the only thing I do after is calculate geometry and fields so you can imagine how frustrated I am with this. How do either of those two things delete every single row?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 22:10:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1271189#M67202</guid>
      <dc:creator>ccowin_odfw</dc:creator>
      <dc:date>2023-03-23T22:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code deleting rows within a feature class?</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1272106#M67244</link>
      <description>&lt;P&gt;Did not test the split layer part, but started with a polygon layer that has multiple, nearly identical polygons.&lt;/P&gt;&lt;P&gt;Testing from this line&amp;nbsp;arcpy.env.workspace = gdb down, I got some really weird results.&lt;/P&gt;&lt;P&gt;Once I changed this line:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;arcpy.management.CalculateGeometryAttributes(WMU, [['Acres', 'AREA_GEODESIC']], area_unit='ACRES_US')

TO

arcpy.management.CalculateGeometryAttributes(WMU, [['Acres', 'AREA_GEODESIC']], area_unit='ACRES')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the rest of the code seems to be working as expected.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 19:24:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1272106#M67244</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2023-03-30T19:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code deleting rows within a feature class?</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1273773#M67312</link>
      <description>&lt;P&gt;That part actually works fine for me, I get an error without the '_US'&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 19:20:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1273773#M67312</guid>
      <dc:creator>ccowin_odfw</dc:creator>
      <dc:date>2023-03-30T19:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this code deleting rows within a feature class?</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1273778#M67313</link>
      <description>&lt;P&gt;That is weird.&amp;nbsp; In either case, it shouldn't have anything to do with deleting rows.&lt;/P&gt;&lt;P&gt;I'm at a loss on this one.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 19:25:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-code-deleting-rows-within-a-feature/m-p/1273778#M67313</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2023-03-30T19:25:59Z</dc:date>
    </item>
  </channel>
</rss>

