Hello community,
I am having a problem adding a logical function into an arcade state I have scraped together from the web. I am not a programmer more of a edit existing code kind of person. I will try to keep this simple.
Here is the expression I have that intersects features and provides results for what its within - landuse info
var intersectLayer =Intersects(FeatureSetByName($map,"LandUse - h Provision Overlay"), Buffer($feature, -10, 'feet'))
var Hazard = "";
for (var f in intersectLayer) {
if (Hazard == "") {
Hazard = f.NAME
} else {
Hazard += " And " + f.NAME;}}
return Hazard
the result is this:
I don't know how to insert a logical function into this expression so empty values display "n/a"
I have tried: IIf , IsEmpty, DefaultValue all kinds I just don't know how to fit them in
any help would be greatly appreciated!!!
Thanks
Aaron
also, can someone explained what the word hazard is for? it was just with the code so I left it in!
thanks again
Solved! Go to Solution.
Ah, I think I misunderstood your original question...
Does this do what you want?
// Get all features of the LandUse layer that are intersected by the selected feature.
// You apply a negative buffer here, so you don't get land use features that only intersect with the outer edges, is that correct?
var intersect_layer = Intersects(FeatureSetByName($map, "LandUse - h Provision Overlay"), Buffer($feature, -10, 'feet'))
// No intersecting features found -> "n/a"
if(Count(intersect_layer) == 0) {
return "n/a"
}
// Define and initialize the variable that stores your text
var intersected_land_uses = ""
// Loop through the intersecting land use features
for (var f in intersect_layer ) {
var land_use = IIF(IsEmpty(f.NAME), "n/a", f.NAME)
if (intersected_land_uses == "") { // there is nothing in here yet
intersected_land_uses = land_use
} else { // there is something in here already, append with " And "
intersected_land_uses += " And " + land_use
}
}
return intersected_land_uses
"Hazard" is the name of the variable that stores your text. You can call it pretty much anything you want, though descriptive names are the most sensible.
// Get all features of the LandUse layer that are intersected by the selected feature.
// You apply a negative buffer here, so you don't get land use features that only intersect with the outer edges, is that correct?
var intersect_layer = Intersects(FeatureSetByName($map, "LandUse - h Provision Overlay"), Buffer($feature, -10, 'feet'))
// Define and initialize the variable that stores your text
var intersected_land_uses = ""
// Loop through the intersecting land use features
for (var f in intersect_layer ) {
var land_use = IIF(IsEmpty(f.NAME), "n/a", f.NAME)
if (intersected_land_uses == "") { // there is nothing in here yet
intersected_land_uses = land_use
} else { // there is something in here already, append with " And "
intersected_land_uses += " And " + land_use
}
}
return intersected_land_uses
wow! thanks!!!
I tried it but it won't display n/a.... am I missing something?
thanks again for your time - very much appreciated
intersect (pink is 'h overlay')
no intersect
So where it says "Hazard", it should say "n/a", right? Or is "Hazard" a land use?
Can you post the code you used, please?
Hello!
No I want it to show n/a after 'h Overlay" as it is outside of zone
Thanks
Ah, I think I misunderstood your original question...
Does this do what you want?
// Get all features of the LandUse layer that are intersected by the selected feature.
// You apply a negative buffer here, so you don't get land use features that only intersect with the outer edges, is that correct?
var intersect_layer = Intersects(FeatureSetByName($map, "LandUse - h Provision Overlay"), Buffer($feature, -10, 'feet'))
// No intersecting features found -> "n/a"
if(Count(intersect_layer) == 0) {
return "n/a"
}
// Define and initialize the variable that stores your text
var intersected_land_uses = ""
// Loop through the intersecting land use features
for (var f in intersect_layer ) {
var land_use = IIF(IsEmpty(f.NAME), "n/a", f.NAME)
if (intersected_land_uses == "") { // there is nothing in here yet
intersected_land_uses = land_use
} else { // there is something in here already, append with " And "
intersected_land_uses += " And " + land_use
}
}
return intersected_land_uses
thanks again for you help but I get this error
Execution Error:Invalid Parameters for Count....?
could I use "Touches' instead of "intersect...?
Intersects and Touches both have pictures indicating what will be selected. Based on your screenshots above, your "h overlay" layer intersects your parcels, so you probably should use Intersects.
I don't know what's wrong with the code, it works for me. Maybe someone else can help? @DanPatterson , @JoeBorgione ?
Thanks!!! I will keep playing with my code!!
Cheers
Aaron