<?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 Python script with memory for intermediate data: wrong calculations in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-with-memory-for-intermediate-data/m-p/1301419#M70441</link>
    <description>&lt;P&gt;I have a python script that uses the georprocessing tools Copy, Intersect, MultipartToSinglepart, RepairGeometry, CalculateField, GenerateNearTable, Sort, Dissolve, Buffer, AddField, JoinField, and da.UpdateCursor.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I write the intermediate data to a Scratch gdb, the model works fine. However, when I write the intermediate data to the /memory, the calculations from the UpdateCursor are not being calculated correctly. The model runs without error messages, but the returned values are wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas why this might be happening?&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jun 2023 09:05:21 GMT</pubDate>
    <dc:creator>IlkaIllers1</dc:creator>
    <dc:date>2023-06-21T09:05:21Z</dc:date>
    <item>
      <title>Python script with memory for intermediate data: wrong calculations</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-with-memory-for-intermediate-data/m-p/1301419#M70441</link>
      <description>&lt;P&gt;I have a python script that uses the georprocessing tools Copy, Intersect, MultipartToSinglepart, RepairGeometry, CalculateField, GenerateNearTable, Sort, Dissolve, Buffer, AddField, JoinField, and da.UpdateCursor.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I write the intermediate data to a Scratch gdb, the model works fine. However, when I write the intermediate data to the /memory, the calculations from the UpdateCursor are not being calculated correctly. The model runs without error messages, but the returned values are wrong.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas why this might be happening?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 09:05:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-with-memory-for-intermediate-data/m-p/1301419#M70441</guid>
      <dc:creator>IlkaIllers1</dc:creator>
      <dc:date>2023-06-21T09:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python script with memory for intermediate data: wrong calculations</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-with-memory-for-intermediate-data/m-p/1301425#M70442</link>
      <description>&lt;P&gt;Is that the order of tool use?&lt;/P&gt;&lt;P&gt;Do all the featureclasses reside in the "\memory" workspace (not in_memory) at the time of processing each step (eg Dissolve)&lt;/P&gt;&lt;P&gt;You are have seen the requirements for "\memory" workspaces I presume&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/basics/the-in-memory-workspace.htm" target="_blank"&gt;Write geoprocessing output to memory—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;And finally&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/updatecursor-class.htm" target="_blank"&gt;UpdateCursor—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Note:&lt;BR /&gt;Using an UpdateCursor on a layer with a joined table is not supported.&lt;/P&gt;&lt;P&gt;Which you seem to have accounted for by using JoinField instead of AddJoin.&lt;/P&gt;&lt;P&gt;Perhaps showing your script would help...although you mention "model towards the end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2023 10:40:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-with-memory-for-intermediate-data/m-p/1301425#M70442</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-06-21T10:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Python script with memory for intermediate data: wrong calculations</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/python-script-with-memory-for-intermediate-data/m-p/1310404#M71292</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I probably mentioned model because it used to be a model which took a long time to run, which is why I wanted to change it into a python script with the intermediate data stored in the memory. It is rather a long script... probably too long to share all of it. I shared the part where the calculation goes wrong.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;# Add and Calculate "Area_ha_in", "Area_perc_in"
arcpy.management.AddField(in_table=_Name_criteria_diss, field_name="Area_ha_in", field_type="DOUBLE")[0]
arcpy.management.AddField(in_table=_Name_criteria_diss , field_name="Area_perc_in", field_type="SHORT")[0]
arcpy.management.AddField(in_table=_Name_criteria_diss, field_name="FID_location_criteria", field_type="TEXT", field_length=1000)[0]
with arcpy.da.UpdateCursor(_Name_criteria_diss, ["Area_ha_in","Area_perc_in","FID_location_criteria","SUM_Shape_Area","Shape_Area_location","FID_common","criteria_ID"]) as cursor:
        for row in cursor:
          z = row[3]/10000
          a = float(str(z).replace(',', '.'))
          b = round(a,2)
          row[0] = b
          u = (row[3]/row[4]) *100
          v = float(str(u).replace(',', '.'))
          w = int(round(v,0))
          row[1] = w
          row[2] = row[5] + row[6]
          cursor.updateRow(row)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 21 Jul 2023 11:08:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/python-script-with-memory-for-intermediate-data/m-p/1310404#M71292</guid>
      <dc:creator>IlkaIllers1</dc:creator>
      <dc:date>2023-07-21T11:08:45Z</dc:date>
    </item>
  </channel>
</rss>

