<?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: Intersect vs iterate when getting attributes from another feature class in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/intersect-vs-iterate-when-getting-attributes-from/m-p/1106989#M257</link>
    <description>&lt;P&gt;I guess you know already, but just to be sure: In Pro 2.7 and later, you can alter multiple attributes with the same rule, so upgrading would be your best option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You outlined 2 possibilities:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;doing the intersect in each rule&lt;/LI&gt;&lt;LI&gt;doing the intersect in the first rule, saving the id in a field, then using that id to filter (&lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#filter" target="_blank" rel="noopener"&gt;Filter()&lt;/A&gt;, you don't need to iterate) the target featureset&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I don't know which one is faster, but my guess would be the second one, because the test for intersection should be more expensive than an sql query. Test it, I guess...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I want to propose another solution:&lt;/P&gt;&lt;P&gt;Create a field that stores a string. In the first rule, you save the intersected feature's attributes in that field:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByName(.....)
var intersect_fs = Intersects($feature, fs)
var intersect_f = First(intersect_fs)

if(intersect_f == null) { return null } // no intersecting feature

var attributes = Dictionary(Text(intersect_f)).attributes
return Text(attributes)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the following rules, you can use that field to extract the values:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if(IsEmpty($feature.IntersectAttributes)) { return null }

var attributes = Dictionary($feature.IntersectAttributes)
return attributes.Attribute&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This way, you need to search the other table only once, which should be the best option performance-wise. You'd need to create an extra field, but you need that in your second proposed solution, too.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Oct 2021 11:00:41 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2021-10-13T11:00:41Z</dc:date>
    <item>
      <title>Intersect vs iterate when getting attributes from another feature class</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/intersect-vs-iterate-when-getting-attributes-from/m-p/1106975#M256</link>
      <description>&lt;P&gt;I need to calculate a number of fields in a feature class based on an intersecting polygon feature class. I'm using AGPro 2.4 so for every field calculation I must create a different attribute rule.&lt;/P&gt;&lt;P&gt;One of the fields I will retrieve from that one polygon feature class is the Id field (which I know is unique) so using intersect is not the only way to get the value from every field. Rule 1 could use intersect to get the value from the Id field and the following rules would iterate through the feature class to find the feature with matching Id field to get the value from the rest of fields.&lt;/P&gt;&lt;P&gt;The question is, what's the best option for better performance? All this will be published to Portal 10.7.1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 10:38:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/intersect-vs-iterate-when-getting-attributes-from/m-p/1106975#M256</guid>
      <dc:creator>AGP</dc:creator>
      <dc:date>2021-10-13T10:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: Intersect vs iterate when getting attributes from another feature class</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/intersect-vs-iterate-when-getting-attributes-from/m-p/1106989#M257</link>
      <description>&lt;P&gt;I guess you know already, but just to be sure: In Pro 2.7 and later, you can alter multiple attributes with the same rule, so upgrading would be your best option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You outlined 2 possibilities:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;doing the intersect in each rule&lt;/LI&gt;&lt;LI&gt;doing the intersect in the first rule, saving the id in a field, then using that id to filter (&lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#filter" target="_blank" rel="noopener"&gt;Filter()&lt;/A&gt;, you don't need to iterate) the target featureset&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I don't know which one is faster, but my guess would be the second one, because the test for intersection should be more expensive than an sql query. Test it, I guess...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I want to propose another solution:&lt;/P&gt;&lt;P&gt;Create a field that stores a string. In the first rule, you save the intersected feature's attributes in that field:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByName(.....)
var intersect_fs = Intersects($feature, fs)
var intersect_f = First(intersect_fs)

if(intersect_f == null) { return null } // no intersecting feature

var attributes = Dictionary(Text(intersect_f)).attributes
return Text(attributes)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the following rules, you can use that field to extract the values:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if(IsEmpty($feature.IntersectAttributes)) { return null }

var attributes = Dictionary($feature.IntersectAttributes)
return attributes.Attribute&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This way, you need to search the other table only once, which should be the best option performance-wise. You'd need to create an extra field, but you need that in your second proposed solution, too.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Oct 2021 11:00:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/intersect-vs-iterate-when-getting-attributes-from/m-p/1106989#M257</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-10-13T11:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: Intersect vs iterate when getting attributes from another feature class</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/intersect-vs-iterate-when-getting-attributes-from/m-p/1108317#M261</link>
      <description>&lt;P&gt;Unfortunately altering the field structure of the feature class is not an option. I'm saving the id in an existing field. That's one of the fields I'm asked to retrieve and I wanted to take advantage of that to get a better option, performance-wise, to calculate the rest of fields.&lt;/P&gt;&lt;P&gt;I will take a look at the Filter function though. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 07:16:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/intersect-vs-iterate-when-getting-attributes-from/m-p/1108317#M261</guid>
      <dc:creator>AGP</dc:creator>
      <dc:date>2021-10-18T07:16:54Z</dc:date>
    </item>
  </channel>
</rss>

