<?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: Calculate a field based on sum of a field from another shape file in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777332#M1035</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your big problem is that the units of area in that file are in square degrees which is pretty useless since it varies latitudinally. as for the division by area, that would be a fixed parameter, once converted&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Mar 2019 12:37:21 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2019-03-27T12:37:21Z</dc:date>
    <item>
      <title>Calculate a field based on sum of a field from another shape file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777331#M1034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to calculate&amp;nbsp;the field "rate" based on "SUM_Shape_Area" with the sum of "Shape_Area" in the second screenshot. So, the formula is "rate = SUM_Shape_Area/sum of Shape_Area". And I want to calculate the sum of Shape_Area first and then export it as a variable, and then use "arcpy.CalculateField_management" to calculate the "rate" field I need. I looked at different methods about how to calculate the sum of the field, but they did not work in my case. Could anyone help me with this? Any kind of help would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/440523_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/440524_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2019 02:55:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777331#M1034</guid>
      <dc:creator>ZhenyuYao</dc:creator>
      <dc:date>2019-03-27T02:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a field based on sum of a field from another shape file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777332#M1035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your big problem is that the units of area in that file are in square degrees which is pretty useless since it varies latitudinally. as for the division by area, that would be a fixed parameter, once converted&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2019 12:37:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777332#M1035</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-03-27T12:37:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a field based on sum of a field from another shape file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777333#M1036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;A href="https://community.esri.com/migrated-users/358604"&gt;Zhenyu Yao&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your ArcGIS Pro, navigate to the Analysis tab, and click on python option.&amp;nbsp;&lt;/P&gt;&lt;P&gt;A window will open, update the paths in the script below and paste it in the python window.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fc = r"path/to/the/table/containting/multiple/ShapeAreaValues"&lt;BR /&gt;summed_total = 0&lt;BR /&gt;with arcpy.da.SearchCursor(fc, "Shape_Area") as cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for row in cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; summed_total = summed_total + row[0]&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;fc_to_update = r"path/to/the/table/to/be/updated"&lt;BR /&gt;fields = ['SUM_Shape_Area', 'rate']&lt;BR /&gt;where_clause = "OBJECTID = 1"&lt;BR /&gt;with arcpy.da.UpdateCursor(fc, fields,where_clause) as cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for row in cursor:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; row[1] = row[0] / summed_total&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cursor.updateRow(row)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if you get any errors.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2019 07:40:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777333#M1036</guid>
      <dc:creator>GurminderBharani1</dc:creator>
      <dc:date>2019-04-01T07:40:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a field based on sum of a field from another shape file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777334#M1037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to throw the conversion from square decimal degrees to projected planar units in otherwise the result will still be in square degrees to the sum of squared degrees&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2019 10:22:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777334#M1037</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-04-01T10:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a field based on sum of a field from another shape file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777335#M1038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about changing the projection to PCS get the values in planar units and then run the script?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2019 10:37:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777335#M1038</guid>
      <dc:creator>GurminderBharani1</dc:creator>
      <dc:date>2019-04-01T10:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate a field based on sum of a field from another shape file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777336#M1039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/add-geometry-attributes.htm" title="https://pro.arcgis.com/en/pro-app/tool-reference/data-management/add-geometry-attributes.htm"&gt;Add Geometry Attributes—Data Management toolbox | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;doesn't produce a new file and enables adding a field of areas in a specified projection.&amp;nbsp; You could then add a new field and do the calculation&lt;/P&gt;&lt;P&gt;A cursor could then be used, but it often quicker to use numpy to get the column out as an array, do the sum and the ratio, then arcpy.da.ExtendTable to add a new field with the results back&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Apr 2019 11:02:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/calculate-a-field-based-on-sum-of-a-field-from/m-p/777336#M1039</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-04-01T11:02:17Z</dc:date>
    </item>
  </channel>
</rss>

