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!
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
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};