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)
Solved! Go to Solution.
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)
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)
Amazing! That works and with minimal loading time for the popup. Thanks Josh!