Select to view content in your preferred language

Arcade expression with nested intersect

228
1
11-20-2025 09:42 AM
Labels (1)
BeccaSettele
Emerging Contributor

I'm trying to create a popup in a webmap that shows the number of species that intersect within a boundary within the selected feature. For example, I select the state of California (from US. State Boundaries layer) and this searches the Endangered Species Ranges layer so that it counts the number of species that are within the Roadless Rule boundaries (another layer) within the state of California. It then also lists out these species.

I've tried with intersect but get hung up on the second intersect as you can't intersect two featuresets. I've attached what I've got so far with the caveat that I'm looking for a way to do that second intersect.

BeccaSettele_0-1763660410621.png

Is this possible in arcade? Or do I need to do some pre-processing in ArcPro by creating these intersected layers and then adding them to the map?

-Becca

0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

When posting code, please use the "Insert/edit code sample" button. This makes it easier to read or copy your code. 

You can create a single feature from the roadlessIntersect FeatureSet and using that in the intersection with the speciesRanges FeatureSet. To do this, loop through the FeatureSet and add the features to an array. Use the Union function to create the single feature from that array.

var roadlessIntersect = Intersects(RoadlessRule, $feature)
var features = []
for (var f in roadlessIntersect) {
  Push(features, f)
}
var roadlessFeature = Union(features)
var speciesIntersect = Intersects(speciesRanges, roadlessFeature)
0 Kudos