Arcade else statement with intersect features

311
1
05-17-2023 01:20 PM
Labels (1)
SWrdno
by
New Contributor

Hello,

I am using the arcade expressions for a popup feature for emergency statuses. When you click on the land parcel of interest, if the parcel intersects with the evacuation polygon it will say the Type field: 'Evacuation Alert'. But if you are not in an evacuation alert area; I would like it to say 'None'. 

 

This is currently how I have the code which is how it is displaying on the below images:

var intersectLayer=Intersects(FeatureSetByName($map,"RDNO Evacuation Areas"), $feature)
for (var f in intersectLayer)
if (IsEmpty(intersectLayer)) {
  return "None"
} else{
    return f.Type
}
 

SWrdno_0-1684353657487.png  

SWrdno_1-1684353684082.png

 

 

 

I have reviewed the other posts from these two below, I don't know what's going wrong here.

https://community.esri.com/t5/arcgis-online-questions/arcade-intersect-returns-null-field-values/td-...

https://community.esri.com/t5/arcgis-pro-questions/arcade-if-else-do-nothing/td-p/207436

0 Kudos
1 Reply
JohannesLindner
MVP Frequent Contributor

You're checking the layer for null, which it never will be.

What you want to do:

  • get the first element of the intersect
    • if there is no intersection, the intersect fs will be empty. calling First() on an empty fs will return null
  • check that element for null

 

var evac_fs = FeatureSetByName($map,"RDNO Evacuation Areas")
var evac = First(Intersects(evac_fs, $feature))
return IIf(evac == null, "None", evac.Type)

 


Have a great day!
Johannes
0 Kudos