Select to view content in your preferred language

Arcade Expression to intersect two featuresets and return count

252
2
Jump to solution
07-24-2024 01:43 PM
AustinCanty1
New Contributor III

I'm trying to make a popup expression that will buffer a line to select intersecting parcels, then return a count of points that are within that resulting featureset of parcels. This is my code representing what I'm attempting, but it seems you cannot intersect two featuresets. How should I go about this?

var parcels = FeatureSetByName($map, "Parcels")
var sites = FeatureSetByName($map, "MHC Inventory Points")
var routes = $feature

//return all parcels within 200 feet of route
var int1 = Intersects(bufferGeodetic($feature, 200, "feet"), parcels)

//return featureset of sites that are within first intersection featureset
// this intersection is giving an execution error
var int2 = Intersects(sites, int1)

return count(int2)

  

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

That's correct, you cannot intersect two featuresets. Popup code is meant to evaluate on the specific clicked feature, not an entire layer. You can write an expression that will do that, but it's not likely to perform very well. But who knows? Worth trying out.

var parcels = FeatureSetByName($map, "Parcels")
var sites = FeatureSetByName($map, "MHC Inventory Points")

//return all parcels within 200 feet of route
var int1 = Intersects(bufferGeodetic($feature, 200, "feet"), parcels)

//merge all intersected parcels into one big geometry
var p_geoms = []
for (var i in int1) {
  Push(p_geoms, Geometry(i))
}

var parcels_merged = Union(p_geoms)

// intersect merged parcels with sites
var int2 = Intersects(sites, parcels_merged)

return count(int2)

//return featureset of sites that are within first intersection featureset
// this intersection is giving an execution error
var int2 = Intersects(sites, int1)

return count(int2)

 

- Josh Carlson
Kendall County GIS

View solution in original post

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

That's correct, you cannot intersect two featuresets. Popup code is meant to evaluate on the specific clicked feature, not an entire layer. You can write an expression that will do that, but it's not likely to perform very well. But who knows? Worth trying out.

var parcels = FeatureSetByName($map, "Parcels")
var sites = FeatureSetByName($map, "MHC Inventory Points")

//return all parcels within 200 feet of route
var int1 = Intersects(bufferGeodetic($feature, 200, "feet"), parcels)

//merge all intersected parcels into one big geometry
var p_geoms = []
for (var i in int1) {
  Push(p_geoms, Geometry(i))
}

var parcels_merged = Union(p_geoms)

// intersect merged parcels with sites
var int2 = Intersects(sites, parcels_merged)

return count(int2)

//return featureset of sites that are within first intersection featureset
// this intersection is giving an execution error
var int2 = Intersects(sites, int1)

return count(int2)

 

- Josh Carlson
Kendall County GIS
0 Kudos
AustinCanty1
New Contributor III

Amazing! That works and with minimal loading time for the popup. Thanks Josh!

0 Kudos