<?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 Intersection within Intersect, or Intersect on filtered layer using Arcade in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077351#M41143</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am working in Portal and I have three layers that I want to function together to provide more information in a popup. The layers include:&lt;BR /&gt;Project Boundary (polygon)&lt;BR /&gt;Parcel Boundary (polygon)&lt;BR /&gt;Wind Turbines (points)&lt;/P&gt;&lt;P&gt;First I want to filter the parcel boundary layer down to only those that are signed leases ("PRCL_STAT_CD = 'LSE'"). Then, when I click on a project boundary, I want the popup to display how many wind turbines fall on signed lease parcels within that project.&lt;/P&gt;&lt;P&gt;Theoretically, I envision this working with the expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Count(Intersects(Turbines, Intersection(Parcel Boundary, $feature)))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;with some additional variables defined, but depending on how I write it I receive the error either "Illegal Argument" or "&lt;SPAN&gt;Spatial Relation cannot accept this parameter type&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;There is also a common project name field between the Parcel Boundary and the Project Boundary which I thought maybe I could use to filter the parcels rather than perform an intersection but I can't figure that out either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my expression currently. If someone could please tell me where I am going wrong I would appreciate it!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var turbines = FeatureSetByName($map, "Preferred Array")
var parcels = FeatureSetById($datastore, /* Prospecting - Status */ "53")
var projname = $feature["PROJECT_NAME"]
var projparcels = Filter(parcels,"PROJ_NM = @projname")
var LSEparcels = Filter(projparcels,"PRCL_STAT_CD = 'LSE'")
Count(Intersects(turbines,LSEparcels))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jul 2021 17:12:54 GMT</pubDate>
    <dc:creator>tahunt01</dc:creator>
    <dc:date>2021-07-09T17:12:54Z</dc:date>
    <item>
      <title>Intersection within Intersect, or Intersect on filtered layer using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077351#M41143</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am working in Portal and I have three layers that I want to function together to provide more information in a popup. The layers include:&lt;BR /&gt;Project Boundary (polygon)&lt;BR /&gt;Parcel Boundary (polygon)&lt;BR /&gt;Wind Turbines (points)&lt;/P&gt;&lt;P&gt;First I want to filter the parcel boundary layer down to only those that are signed leases ("PRCL_STAT_CD = 'LSE'"). Then, when I click on a project boundary, I want the popup to display how many wind turbines fall on signed lease parcels within that project.&lt;/P&gt;&lt;P&gt;Theoretically, I envision this working with the expression:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Count(Intersects(Turbines, Intersection(Parcel Boundary, $feature)))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;with some additional variables defined, but depending on how I write it I receive the error either "Illegal Argument" or "&lt;SPAN&gt;Spatial Relation cannot accept this parameter type&lt;/SPAN&gt;"&lt;/P&gt;&lt;P&gt;There is also a common project name field between the Parcel Boundary and the Project Boundary which I thought maybe I could use to filter the parcels rather than perform an intersection but I can't figure that out either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my expression currently. If someone could please tell me where I am going wrong I would appreciate it!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var turbines = FeatureSetByName($map, "Preferred Array")
var parcels = FeatureSetById($datastore, /* Prospecting - Status */ "53")
var projname = $feature["PROJECT_NAME"]
var projparcels = Filter(parcels,"PROJ_NM = @projname")
var LSEparcels = Filter(projparcels,"PRCL_STAT_CD = 'LSE'")
Count(Intersects(turbines,LSEparcels))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 17:12:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077351#M41143</guid>
      <dc:creator>tahunt01</dc:creator>
      <dc:date>2021-07-09T17:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection within Intersect, or Intersect on filtered layer using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077381#M41147</link>
      <description>&lt;P&gt;The problem with that first expression is that &lt;STRONG&gt;Intersection&lt;/STRONG&gt; takes two individual geometries, not FeatureSets. The problem with the second expression is that &lt;STRONG&gt;Intersects&lt;/STRONG&gt; can take a single FeatureSet, but not two.&lt;/P&gt;&lt;P&gt;What you need is some way of intersecting the turbines with a single feature. A simple for-loop can accomplish this.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var out_count = 0

for(var t in turbines){
    if(Intersects(LSEparcels, t)){
        out_count += 1
    }
}

return out_count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 18:22:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077381#M41147</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-07-09T18:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection within Intersect, or Intersect on filtered layer using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077767#M41156</link>
      <description>&lt;P&gt;Thank you for your input Josh! I replaced the last line of my expression with what you provided above but it is returning a value of '0' for everything. I wonder if this is because even after the filters, LSEparcels contains multiple features (there are many LSE parcels within each project). Do I need some sort of for-loop for both the turbines AND the LSEparcels? Is that possible?&lt;/P&gt;&lt;P&gt;Thank you again for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 13:06:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077767#M41156</guid>
      <dc:creator>tahunt01</dc:creator>
      <dc:date>2021-07-12T13:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection within Intersect, or Intersect on filtered layer using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077772#M41157</link>
      <description>&lt;P&gt;It is possible, but I don't believe it's necessary. Since the LSEparcels is itself a FeatureSet, Intersects will return &lt;STRONG&gt;true&lt;/STRONG&gt; if the given turbine intersects with &lt;EM&gt;anything&lt;/EM&gt; in the set.&lt;/P&gt;&lt;P&gt;In order to check on your code, it can be helpful to include &lt;STRONG&gt;Console&lt;/STRONG&gt; statements. Try the following code, then click over to the &lt;STRONG&gt;Messages&lt;/STRONG&gt; tab after it runs. This will help you identify where problems may be occurring, whether it's an issue with the intersection, filter, etc.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1626096232805.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/18222i6922FBA6EBA43CF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1626096232805.png" alt="jcarlson_0-1626096232805.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var turbines = FeatureSetByName($map, "Preferred Array")
Console(`Turbines: ${Count(turbines)}`)

var parcels = FeatureSetById($datastore, /* Prospecting - Status */ "53")
Console(`Parcels: ${Count(parcels)}`)

var projname = $feature["PROJECT_NAME"]

var projparcels = Filter(parcels,"PROJ_NM = @projname")
Console(`Project Parcels: ${Count(projparcels)}`)

var LSEparcels = Filter(parcels, "PRCL_STAT_CD = 'LSE')
Console(`LSE Parcels: ${Count(LSEparcels)}`)

var out_count = 0

for(var t in turbines){
    if(Intersects(LSEparcels, t)){
        out_count += 1
    }
}

return out_count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 14:20:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077772#M41157</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-07-12T14:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection within Intersect, or Intersect on filtered layer using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077800#M41160</link>
      <description>&lt;P&gt;Using the Console messages, I can see that all of my variables are functioning properly, but again the Count(Intersects(turbines,LSEparcels) expression returns an error that the "Spatial Relationship cannot accept this parameter type"&lt;/P&gt;&lt;P&gt;Ultimately it returns many turbines (all of them), and many LSE parcels within the selected project boundary.&lt;/P&gt;&lt;P&gt;For the sample project boundary that's being referenced within the "playground", there are 83 LSE parcels.&lt;/P&gt;&lt;P&gt;To reiterate what I'm after - when I click on the project boundary, I want to know how many turbines fall on those 83 LSE parcels.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not sure if this helps clarify my task or muddy the waters. Let me know if there's any additional info I can provide.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 14:15:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077800#M41160</guid>
      <dc:creator>tahunt01</dc:creator>
      <dc:date>2021-07-12T14:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection within Intersect, or Intersect on filtered layer using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077805#M41161</link>
      <description>&lt;P&gt;What you're looking for makes sense, but remember that Intersects can only accept a single FeatureSet parameter. The expression &lt;STRONG&gt;Intersects(turbines,LSEparcels) &lt;/STRONG&gt;contains two. That why I suggested the for-loop, but I realize I re-pasted the earlier expression in my response about console messages. I'll edit the code snippet in that response.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 14:19:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077805#M41161</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-07-12T14:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: Intersection within Intersect, or Intersect on filtered layer using Arcade</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077884#M41168</link>
      <description>&lt;P&gt;I figured out the solution!&lt;/P&gt;&lt;P&gt;By referencing your solution to a similar problem on a different thread, I added a couple of lines to what you provided above and was able to make this work.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var final_count = 0

// Iterate over LSEparcels FeatureSet and get intersected turbines for each

for(var p in LSEparcels){
    var t_count = Count(Intersects(turbines, p))
    final_count += t_count
}

return "There are " + final_count + " turbines on signed lease parcels for this project"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for helping me work through this. I appreciate it very much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 16:11:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/intersection-within-intersect-or-intersect-on/m-p/1077884#M41168</guid>
      <dc:creator>tahunt01</dc:creator>
      <dc:date>2021-07-12T16:11:27Z</dc:date>
    </item>
  </channel>
</rss>

