Select to view content in your preferred language

Returning attributes from another layer via Arcade intersect?

1178
2
07-19-2023 06:42 AM
DaveK
by
Occasional Contributor

Hello! 

I'm creating an Acrade expression that will allow me to return attribute information from another layer via an intersect. In this case wetland information will be returned when a parcel is clicked on. My current expression works but I cant seem to figure out how to return text that says "No Wetland" when there is no intersecting wetland. Any help is appreciated. 

Arcade Expression:

var points =FeatureSetByName($map,"WetlandsLayer");
var countp = Intersects(points,$feature);

var result = "";
for (var item in countp){
var id = item["LABEL12"];
result += id + ' '
}
return result

Thanks!

Tags (3)
0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

Easy enough! You can check to see how many features are in the intersection, and return a different value when it's 0.

var points =FeatureSetByName($map,"WetlandsLayer");
var countp = Intersects(points,$feature);

if (Count(countp) < 1) {
  return 'No Wetlands'
}

var result = "";
for (var item in countp){
  var id = item["LABEL12"];
  result += id + ' '
}
return result
- Josh Carlson
Kendall County GIS
drWood
by
New Contributor III

The below code is what I recently put together to achieve the same outcome with use of an Attribute Rule. Josh's suggestion is also valid.

var basins = FeatureSetByName ($datastore, "Watersheds_2017", ["WATERSHED_CODE"],true);

var matchedBasin = First(Intersects(basins, Geometry($feature)));

if(matchedBasin == null) {return null}

else {return matchedBasin.WATERSHED_CODE};

 

0 Kudos