I'm attempting to create a featureset in ops dashboards to return the number of points contained within a polygon, however I'm getting the same number of points for each polygon. Am I missing something in my data expression? I'm in Enterprise 10.9.1.
var portal = Portal('myportal')
var poly_fs = FeatureSetByPortalItem(portal, 'c879aa9267604224a3f6d492fc997a50', 7,['ZONE_NAME'],true)
var pt_fs = FeatureSetByPortalItem(portal, '44fa0f9330e449c289dfadf2553d805b', 0,['leaktype','leakloss',],true)
var features = []
var feat
for (var poly in poly_fs){
var pts = Contains(poly, pt_fs)
feat = {attributes:{
mmz: zone['ZONE_NAME'],
number_of_leaks: Count(leaks)
}
}
Push(features,feat)
}
var dict = {
fields:[
{name:"mmz",alias:"Zone",type:"esriFieldTypeString"},
{name:"number_of_leaks",alias:"Number of Leaks",type:"esriFieldTypeInteger"}
],
geometryType:"",
features:features
}
return FeatureSet(Text(dict))
Solved! Go to Solution.
In that case, you want to get the count of how many point were in the polygon, so it should be
number_of_leaks: Count(pts)
Where is the variable "leaks" coming from in this section?
for (var poly in poly_fs){
var pts = Contains(poly, pt_fs)
feat = {attributes:
{
mmz: zone['ZONE_NAME'],
number_of_leaks: Count(leaks)
}
}
Push(features,feat)
}
Sorry, that should say 'pt_fs'. I changed variable names for this post.
In that case, you want to get the count of how many point were in the polygon, so it should be
number_of_leaks: Count(pts)
That worked. Thanks!