Arcade - Intersecting Polygons - return multiple answers if multiple.

503
3
Jump to solution
12-12-2019 10:47 AM
TrishaSchlake
New Contributor III

Hi Xander Bakker

 

I have a parcel feature layer and a soils feature layer in my webmap. I'm trying to apply the arcade to my parcels layer so that when a parcel is clicked it will give me the corresponding soils to that parcel. The issue is that there could be more than one soil per parcel. The expression I currently have applied to my parcel feature class is this: 

 

 var intersectLayer = Intersects(FeatureSetByName($map,"STATSGO2Soils"), $feature)
for(var f in intersectLayer){
return f.muname
}

 

But it will only return one of my soils into the parcel and will not bring in multiple soils names. Is there a way to do what I'm hoping to do? 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Honored Contributor

Try this instead.

var intersectLayer = Intersects(FeatureSetByName($map,"STATSGO2Soils"), $feature)
var results = "";
for(var f in intersectLayer){
  if (results == "") {
    results = f.muname;
  } else {
    results += ", " + f.muname;
  }
}
return results;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

This would be another way

var intersectLayer = Intersects(FeatureSetByName($map,"STATSGO2Soils"), $feature)
var results = [];
for(var f in intersectLayer){
  results[Count(results)] = f.muname;
}
return Concatenate(results, ", ");‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

3 Replies
KenBuja
MVP Honored Contributor

Try this instead.

var intersectLayer = Intersects(FeatureSetByName($map,"STATSGO2Soils"), $feature)
var results = "";
for(var f in intersectLayer){
  if (results == "") {
    results = f.muname;
  } else {
    results += ", " + f.muname;
  }
}
return results;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

This would be another way

var intersectLayer = Intersects(FeatureSetByName($map,"STATSGO2Soils"), $feature)
var results = [];
for(var f in intersectLayer){
  results[Count(results)] = f.muname;
}
return Concatenate(results, ", ");‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
TrishaSchlake
New Contributor III

Thank you Ken! That is exactly what I needed. I appreciate the quick help! 

0 Kudos
KenBuja
MVP Honored Contributor

Glad to help (and check out the alternate code).

Please don't forget to mark the question as answered.

0 Kudos