Select to view content in your preferred language

FeatureSet Not Returning the Correct Value

506
4
Jump to solution
10-18-2022 06:50 AM
ChelseaTabor
New Contributor III

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.

ChelseaTabor_1-1666100491398.png

 

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))

 

 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

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)

 

View solution in original post

0 Kudos
4 Replies
KenBuja
MVP Esteemed Contributor

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)
}
0 Kudos
ChelseaTabor
New Contributor III

Sorry, that should say 'pt_fs'.  I changed variable names for this post. 

0 Kudos
KenBuja
MVP Esteemed Contributor

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)

 

0 Kudos
ChelseaTabor
New Contributor III

That worked. Thanks!

0 Kudos