<?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 Field with Python/ Arcade in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005030#M37534</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/422686"&gt;@NoahLeimgruber&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;It seems to be working:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="XanderBakker_0-1606402284990.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/1057i43CBE8805A707E0A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="XanderBakker_0-1606402284990.png" alt="XanderBakker_0-1606402284990.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I did notice that there are some polygons that have -1 for the H1 and H2 values and many have an H2 values that is equal to H1 +1. When selecting only those polygons that are larger than H1 and smaller than H2, you will not get any resulting polygon and a catchment area of 0. Is that correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I used is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def main():
    # load arcpy
    import arcpy

    # set reference to the featureclass
    fc = r'D:\GeoNet\CatchmentArea\Data.shp' # change this

    # create dictionary with H values and areas
    flds1 = ("OID@", "H1", "H2", "SHAPE@AREA")
    dct = {r[0]: [r[1], r[2], r[3]] for r in arcpy.da.SearchCursor(fc, flds1)}

    # start update cursor to write the catchment areas
    flds2 = ("OID@", "Einzugsgeb")
    with arcpy.da.UpdateCursor(fc, flds2) as curs:
        for row in curs:
            # read values
            oidcurr = row[0]
            # determine catchment area
            catchment = SumAreaInRangeH(oidcurr, dct)
            row[1] = catchment
            curs.updateRow(row)


def SumAreaInRangeH(oidcurr, dct):
    # function to determine catchment area
    sumarea = -1
    if oidcurr in dct:
        # set reference values
        h1 = dct[oidcurr][0]
        h2 = dct[oidcurr][1]
        sumarea = 0
        for oid, lst in dct.items():
            if oid != oidcurr and lst[0] &amp;gt; h1 and lst[1] &amp;lt; h2:
                sumarea += lst[2]
    return sumarea


if __name__ == '__main__':
    main()&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 26 Nov 2020 14:53:52 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2020-11-26T14:53:52Z</dc:date>
    <item>
      <title>Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1004636#M37508</link>
      <description>&lt;P&gt;HI all!&lt;/P&gt;&lt;P&gt;I want to execute a Python/Arcade command in ArcGIS Calculate Field which gives me a result for the catchment area (table).&lt;BR /&gt;The command should select all IDs in the list that have an X-value greater than the ID to be calculated (Here ID 1) and a Y-value less than the ID to be calculated (Here ID 1).&lt;BR /&gt;From the selected IDs, the respective areas should then be summed up and saved to the catchment area field.&lt;/P&gt;&lt;P&gt;In this example, the X and Y values of IDs 2 and 3 fulfill the condition. Thus, the respective areas would be added together, which would result in 15. The result would be stored in the catchment area of ID 1.&lt;/P&gt;&lt;P&gt;Thank you very much for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="128"&gt;&lt;P&gt;ID&lt;/P&gt;&lt;/TD&gt;&lt;TD width="121"&gt;&lt;P&gt;X&lt;/P&gt;&lt;/TD&gt;&lt;TD width="121"&gt;&lt;P&gt;Y&lt;/P&gt;&lt;/TD&gt;&lt;TD width="122"&gt;&lt;P&gt;area&lt;/P&gt;&lt;/TD&gt;&lt;TD width="112"&gt;&lt;P&gt;catchment area&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="128"&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="121"&gt;&lt;P&gt;1000&lt;/P&gt;&lt;/TD&gt;&lt;TD width="121"&gt;&lt;P&gt;2000&lt;/P&gt;&lt;/TD&gt;&lt;TD width="122"&gt;&lt;P&gt;23&lt;/P&gt;&lt;/TD&gt;&lt;TD width="112"&gt;&lt;P&gt;? (15)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="128"&gt;&lt;P&gt;2&lt;/P&gt;&lt;/TD&gt;&lt;TD width="121"&gt;&lt;P&gt;1034&lt;/P&gt;&lt;/TD&gt;&lt;TD width="121"&gt;&lt;P&gt;1083&lt;/P&gt;&lt;/TD&gt;&lt;TD width="122"&gt;&lt;P&gt;10&lt;/P&gt;&lt;/TD&gt;&lt;TD width="112"&gt;&lt;P&gt;…&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="128"&gt;&lt;P&gt;3&lt;/P&gt;&lt;/TD&gt;&lt;TD width="121"&gt;&lt;P&gt;1599&lt;/P&gt;&lt;/TD&gt;&lt;TD width="121"&gt;&lt;P&gt;1743&lt;/P&gt;&lt;/TD&gt;&lt;TD width="122"&gt;&lt;P&gt;5&lt;/P&gt;&lt;/TD&gt;&lt;TD width="112"&gt;&lt;P&gt;…&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="128"&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD width="121"&gt;&lt;P&gt;1403&lt;/P&gt;&lt;/TD&gt;&lt;TD width="121"&gt;&lt;P&gt;2004&lt;/P&gt;&lt;/TD&gt;&lt;TD width="122"&gt;&lt;P&gt;34&lt;/P&gt;&lt;/TD&gt;&lt;TD width="112"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 25 Nov 2020 13:00:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1004636#M37508</guid>
      <dc:creator>NoahLeimgruber</dc:creator>
      <dc:date>2020-11-25T13:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1004753#M37517</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/422686"&gt;@NoahLeimgruber&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I probably would advise you to use Python for this one and use a dictionary to store the values and easy access, although I wouldn't do this using a Field Calculation (preferably, I would use a standalone script). With Arcade you would probably end up using multiple requests on the data which would result in longer processing times.&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, is this "static" data or is this data dynamic and requires an update of this logic when data is edited? In that case I would probably go for an attribute rule using Arcade.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just to be clear... when you calculate the catchment area for ID 1 you don't include the area of ID 1 in the result, right?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 18:44:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1004753#M37517</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2020-11-25T18:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1004777#M37519</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your answer and your suggestions! Unfortunately I'm a **bleep** beginner when it comes to coding so I don't understand exactly what you mean in the first section.&lt;/P&gt;&lt;P&gt;The data is "static".&lt;/P&gt;&lt;P&gt;and yes that is correct, i don't want to include the area of ID 1 in the calculation&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 19:25:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1004777#M37519</guid>
      <dc:creator>NoahLeimgruber</dc:creator>
      <dc:date>2020-11-25T19:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1004888#M37521</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/422686"&gt;@NoahLeimgruber&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I could write some code to do this, but it would be easier to have some (dummy) data with the same schema to test with. Any chance that you could share some (dummy) data for this?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 23:24:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1004888#M37521</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2020-11-25T23:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005001#M37529</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much, you are absolutely amazing!&lt;/P&gt;&lt;P&gt;I' ve created a WeTranfer link with the data inside because I could not upload the file here because it is bigger than 5MB:&lt;/P&gt;&lt;P&gt;&lt;A href="https://we.tl/t-euedapBzW8" target="_blank" rel="noopener"&gt;https://we.tl/t-euedapBzW8&lt;/A&gt;&lt;/P&gt;&lt;P&gt;H1 refers to X and H2 to Y&lt;/P&gt;&lt;P&gt;by "Einzugsgeb" is meant the catchment area&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 13:25:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005001#M37529</guid>
      <dc:creator>NoahLeimgruber</dc:creator>
      <dc:date>2020-11-26T13:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005021#M37532</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/422686"&gt;@NoahLeimgruber&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for sharing. I will have a look and post back any results or questions that may arrise.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 13:42:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005021#M37532</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2020-11-26T13:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005030#M37534</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/422686"&gt;@NoahLeimgruber&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;It seems to be working:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="XanderBakker_0-1606402284990.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/1057i43CBE8805A707E0A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="XanderBakker_0-1606402284990.png" alt="XanderBakker_0-1606402284990.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I did notice that there are some polygons that have -1 for the H1 and H2 values and many have an H2 values that is equal to H1 +1. When selecting only those polygons that are larger than H1 and smaller than H2, you will not get any resulting polygon and a catchment area of 0. Is that correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I used is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def main():
    # load arcpy
    import arcpy

    # set reference to the featureclass
    fc = r'D:\GeoNet\CatchmentArea\Data.shp' # change this

    # create dictionary with H values and areas
    flds1 = ("OID@", "H1", "H2", "SHAPE@AREA")
    dct = {r[0]: [r[1], r[2], r[3]] for r in arcpy.da.SearchCursor(fc, flds1)}

    # start update cursor to write the catchment areas
    flds2 = ("OID@", "Einzugsgeb")
    with arcpy.da.UpdateCursor(fc, flds2) as curs:
        for row in curs:
            # read values
            oidcurr = row[0]
            # determine catchment area
            catchment = SumAreaInRangeH(oidcurr, dct)
            row[1] = catchment
            curs.updateRow(row)


def SumAreaInRangeH(oidcurr, dct):
    # function to determine catchment area
    sumarea = -1
    if oidcurr in dct:
        # set reference values
        h1 = dct[oidcurr][0]
        h2 = dct[oidcurr][1]
        sumarea = 0
        for oid, lst in dct.items():
            if oid != oidcurr and lst[0] &amp;gt; h1 and lst[1] &amp;lt; h2:
                sumarea += lst[2]
    return sumarea


if __name__ == '__main__':
    main()&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 26 Nov 2020 14:53:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005030#M37534</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2020-11-26T14:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005035#M37535</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/422686"&gt;@NoahLeimgruber&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking a bit closer to the results I notice that in the Northern part there are some polygons with a huge catchment area. I also notice that they are summing the same polygon areas. If this is about catchments I don't think that this is hydrologically correct, but maybe the calculation has a different purpose.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 15:12:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005035#M37535</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2020-11-26T15:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005055#M37536</link>
      <description>&lt;P&gt;First of all thank you for your work and your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I did notice that there are some polygons that have -1 for the H1 and H2 values and many have an H2 values that is equal to H1 +1. When selecting only those polygons that are larger than H1 and smaller than H2, you will not get any resulting polygon and a catchment area of 0. Is that correct?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;Yes that's right, something is not 100% correct.&lt;BR /&gt;I just realized that it makes more sense if the H1 or H2 value can also be the same as the ID to be calculated.&lt;BR /&gt;So greater and equal than H1 and less and equal than H2. (not greater than H1 and less than H2)&lt;BR /&gt;This solves the problem with the 0 values, because at least the own area is included.&lt;/P&gt;&lt;P&gt;I don't understand why some attributes have a -1 value. but we lets ignore that...&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 17:28:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005055#M37536</guid>
      <dc:creator>NoahLeimgruber</dc:creator>
      <dc:date>2020-11-26T17:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005057#M37537</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;I also notice that they are summing the same polygon areas.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What do you mean by that exactly?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 17:30:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005057#M37537</guid>
      <dc:creator>NoahLeimgruber</dc:creator>
      <dc:date>2020-11-26T17:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005073#M37539</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/422686"&gt;@NoahLeimgruber&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;To include the min and max values in the range and also include the area of the polygon itself, you just need to change this line:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if oid != oidcurr and lst[0] &amp;gt; h1 and lst[1] &amp;lt; h2:&lt;/LI-CODE&gt;&lt;P&gt;into this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if lst[0] &amp;gt;= h1 and lst[1] &amp;lt;= h2:&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will assign a catchment area value to all polygons:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="XanderBakker_0-1606418720715.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/1067iC19394B3FF5AF3FB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="XanderBakker_0-1606418720715.png" alt="XanderBakker_0-1606418720715.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 19:26:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005073#M37539</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2020-11-26T19:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005363#M37550</link>
      <description>&lt;P&gt;hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;, the code works perfectly! thank you very much! you were a great help&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 11:18:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1005363#M37550</guid>
      <dc:creator>NoahLeimgruber</dc:creator>
      <dc:date>2020-11-29T11:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1017750#M38041</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for asking you again!&lt;/P&gt;&lt;P&gt;How do I need to change the code if the value to be summed up is not from the shape area ("SHAPE@AREA"), but from a field called "Q347"?&lt;/P&gt;&lt;P&gt;I already tried it with no luck. Maybe you have a short answer to this. If not, no worries.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 20:23:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1017750#M38041</guid>
      <dc:creator>NoahLeimgruber</dc:creator>
      <dc:date>2021-01-18T20:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1017753#M38042</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/422686"&gt;@NoahLeimgruber&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as I can see you should only have to change the line...&lt;/P&gt;&lt;LI-CODE lang="python"&gt;flds1 = ("OID@", "H1", "H2", "SHAPE@AREA")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;into:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;flds1 = ("OID@", "H1", "H2", "Q347")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 18 Jan 2021 20:32:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1017753#M38042</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-01-18T20:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1017755#M38043</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, that is exactly what I tried. But then I get the following error code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 000539: Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 39, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 19, in main&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 34, in SumAreaInRangeH&lt;BR /&gt;TypeError: unsupported operand type(s) for +=: 'float' and 'NoneType'&lt;BR /&gt;Failed to execute (CalculateField).&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 20:43:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1017755#M38043</guid>
      <dc:creator>NoahLeimgruber</dc:creator>
      <dc:date>2021-01-18T20:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1017757#M38044</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/422686"&gt;@NoahLeimgruber&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;It looks like you have None (null) values in your Q347 field.&lt;/P&gt;&lt;P&gt;You can put an additional validation in the function:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def SumAreaInRangeH(oidcurr, dct):
    # function to determine catchment area
    sumarea = -1
    if oidcurr in dct:
        # set reference values
        h1 = dct[oidcurr][0]
        h2 = dct[oidcurr][1]
        sumarea = 0
        for oid, lst in dct.items():
            if oid != oidcurr and lst[0] &amp;gt; h1 and lst[1] &amp;lt; h2:
                if lst[2] is not None:
                    sumarea += lst[2]
    return sumarea&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 20:55:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1017757#M38044</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-01-18T20:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field with Python/ Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1017758#M38045</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1108"&gt;@XanderBakker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Okay now it just worked. the problem were " NA " values in the column " Q347 ".&lt;BR /&gt;Thank you very much anyway&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 20:55:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/calculate-field-with-python-arcade/m-p/1017758#M38045</guid>
      <dc:creator>NoahLeimgruber</dc:creator>
      <dc:date>2021-01-18T20:55:26Z</dc:date>
    </item>
  </channel>
</rss>

