<?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: ArcGIS Pro 3.1.2 - How to create variable with all features in Arcade? in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-1-2-how-to-create-variable-with-all/m-p/1319635#M72190</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Finally, I am trying to use the $layer global variable to loop through all features in order to sum acreage per cities. The Arcade expression makes an initial distinct list of cities in the $layer and then calculates acreage acreage accordingly for each $feature, as follow:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var myArray = [];
var i = 0;
for(var z in $layer) {
    Insert(myArray, i, z.City);
    i = i + 1;
}

var myArrayDistinct = Distinct(myArray);
var myArrayDistinctSort = Sort(myArrayDistinct);

var acreage = 0;

for(var a in myArrayDistinctSort) {
    for(var z in $layer) {
        if (z.City == myArrayDistinctSort[a]) {
            acreage = acreage + z.AreaGeodetic(z, 'acres');
        }
    }
}
return acreage;&lt;/LI-CODE&gt;&lt;P&gt;but I still get an:&lt;/P&gt;&lt;P&gt;Invalid expression.&lt;BR /&gt;Error on line 3.&lt;BR /&gt;Object not found $layer&lt;/P&gt;&lt;P&gt;For info, I am using this Arcade expression in Calculate field tool.&lt;/P&gt;&lt;P&gt;Any guess?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2023 15:09:47 GMT</pubDate>
    <dc:creator>VincentLaunstorfer</dc:creator>
    <dc:date>2023-08-17T15:09:47Z</dc:date>
    <item>
      <title>ArcGIS Pro 3.1.2 - How to create variable with all features in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-1-2-how-to-create-variable-with-all/m-p/1305793#M70820</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have an Arcade expression in which I would like to look through all features for calculation.&lt;/P&gt;&lt;P&gt;I start my expression as:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var Zoning = FeatureSetByName($layer,["City"],true);&lt;/LI-CODE&gt;&lt;P&gt;I would like to use the variable 'Zoning' to loop in order to calculate in each $feature using the 'City' attribute and the geometry (hence 'True')&lt;/P&gt;&lt;P&gt;In Arcade, I though I could simply point to the current layer using $layer but it does not work!&lt;/P&gt;&lt;P&gt;For info, I am using this Arcade expression in Calculate Field in Model Builder and I cannot easily reference the $datastore name as it is dynamic.&lt;/P&gt;&lt;P&gt;Any help&amp;nbsp; appreciated&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2023 16:07:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-1-2-how-to-create-variable-with-all/m-p/1305793#M70820</guid>
      <dc:creator>VincentLaunstorfer</dc:creator>
      <dc:date>2023-07-05T16:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.1.2 - How to create variable with all features in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-1-2-how-to-create-variable-with-all/m-p/1305903#M70832</link>
      <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#featuresetbyname" target="_blank" rel="noopener"&gt;FeaturesetByName()&lt;/A&gt; asks for a Featureset Collection. $layer is a Featureset (the Featureset that the current $feature belongs to).&lt;/P&gt;&lt;P&gt;To loop through each feature in the current layer, you can just use the $layer global like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;for(var f in $layer) {
    // do something with f
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 05 Jul 2023 19:06:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-1-2-how-to-create-variable-with-all/m-p/1305903#M70832</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-07-05T19:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.1.2 - How to create variable with all features in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-1-2-how-to-create-variable-with-all/m-p/1306229#M70857</link>
      <description>&lt;P&gt;Fantastic!&lt;/P&gt;&lt;P&gt;I will try that. I knew there was something easy.&lt;/P&gt;&lt;P&gt;Appreciated&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2023 16:00:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-1-2-how-to-create-variable-with-all/m-p/1306229#M70857</guid>
      <dc:creator>VincentLaunstorfer</dc:creator>
      <dc:date>2023-07-06T16:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.1.2 - How to create variable with all features in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-1-2-how-to-create-variable-with-all/m-p/1319635#M72190</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Finally, I am trying to use the $layer global variable to loop through all features in order to sum acreage per cities. The Arcade expression makes an initial distinct list of cities in the $layer and then calculates acreage acreage accordingly for each $feature, as follow:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var myArray = [];
var i = 0;
for(var z in $layer) {
    Insert(myArray, i, z.City);
    i = i + 1;
}

var myArrayDistinct = Distinct(myArray);
var myArrayDistinctSort = Sort(myArrayDistinct);

var acreage = 0;

for(var a in myArrayDistinctSort) {
    for(var z in $layer) {
        if (z.City == myArrayDistinctSort[a]) {
            acreage = acreage + z.AreaGeodetic(z, 'acres');
        }
    }
}
return acreage;&lt;/LI-CODE&gt;&lt;P&gt;but I still get an:&lt;/P&gt;&lt;P&gt;Invalid expression.&lt;BR /&gt;Error on line 3.&lt;BR /&gt;Object not found $layer&lt;/P&gt;&lt;P&gt;For info, I am using this Arcade expression in Calculate field tool.&lt;/P&gt;&lt;P&gt;Any guess?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 15:09:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-1-2-how-to-create-variable-with-all/m-p/1319635#M72190</guid>
      <dc:creator>VincentLaunstorfer</dc:creator>
      <dc:date>2023-08-17T15:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro 3.1.2 - How to create variable with all features in Arcade?</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-1-2-how-to-create-variable-with-all/m-p/1319993#M72233</link>
      <description>&lt;P&gt;I think I found out the reason why global variable $layer gives an Object not found error.&lt;/P&gt;&lt;P&gt;In Field Calculation profile, only $feature and $datastore can be used in Aracde. Not $layer.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/profiles/field-calculation/" target="_self"&gt;https://developers.arcgis.com/arcade/profiles/field-calculation/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I use this this Arcade expression in Field Calculation in ModelBuilder with a dynamic feature class name, I have no chance to re-use the ModelBuilder variable pointing to my feature class in the Arcade script...&lt;/P&gt;&lt;P&gt;Never mind, I will perform my calculation differently.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2023 08:11:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-3-1-2-how-to-create-variable-with-all/m-p/1319993#M72233</guid>
      <dc:creator>VincentLaunstorfer</dc:creator>
      <dc:date>2023-08-18T08:11:13Z</dc:date>
    </item>
  </channel>
</rss>

