Hi brains trust. I'm trying to use Arcade to calculate a value in Field Maps based on the intersection of the new point feature with 2 underlying polygons layers.
I've successfully managed to get a value from a field in one layer, but I want it to test it for null values and then return a value from a second layer if null = true.
var BufferedFeature = Buffer($feature, 20, 'meters')
var intersectLayer1 = Intersects(FeatureSetByName($map, 'Layer1'),BufferedFeature)
var intersectLayer2 = Intersects(FeatureSetByName($map, 'Layer2'),BufferedFeature)
for (var f in intersectLayer1){
var name1 = f.Field
}
for (var f in intersectLayer2){
var name2 = f.Field
}
IIf(name1=='',name2,name1)
var BufferedFeature = Buffer($feature, 20, 'meters')
var intersectLayer1 = Intersects(FeatureSetByName($map, 'Layer1'),BufferedFeature)
var intersectLayer2 = Intersects(FeatureSetByName($map, 'Layer2'),BufferedFeature)
for (var f in intersectLayer1){
IsEmpty(f.Field)=='true';
for (var f in intersectLayer2){
return f.Field
}
return f1.Field
}
I've tried a few variations of the above codes, and the Field value from Layer 1 returns correctly when it does intersect, but can't get it to return the Field value from Layer 2 when Layer 1 does NOT intersect (and Layer 2 does).
Solved! Go to Solution.
Oh, my answer checks if there are any features in intersectLayer1. If you want to check for null values in Field, you can do that like this:
// returns the value of the first non-empty field "Field"
for(var f in intersectLayer1) {
if(!IsEmpty(f.Field)) {
return f.Field
}
}
for(var f in intersectLayer2) {
if(!IsEmpty(f.Field)) {
return f.Field
}
}
return "nothing found"
var featureLayer1 = First(intersectLayer1)
var featureLayer2 = First(intersectLayer2)
if(featureLayer1 != null) {
return featureLayer1.Field
}
if(featureLayer2 != null) {
return featureLayer2.Field
}
return "nothing found"
or (same output, a little shorter)
for(var f in intersectLayer1) {
return f.Field
}
for(var f in intersectLayer2) {
return f.Field
}
return "nothing found"
Oh, my answer checks if there are any features in intersectLayer1. If you want to check for null values in Field, you can do that like this:
// returns the value of the first non-empty field "Field"
for(var f in intersectLayer1) {
if(!IsEmpty(f.Field)) {
return f.Field
}
}
for(var f in intersectLayer2) {
if(!IsEmpty(f.Field)) {
return f.Field
}
}
return "nothing found"
You're a champ! That works perfectly. Thank you muchly.