Select to view content in your preferred language

Trying to create a list of intersecting features using arcade expression

1522
5
Jump to solution
02-10-2022 08:28 AM
Labels (1)
cpenling
New Contributor III

I'm trying to create a list of lakes (polygon features) within a region (polygon feature) using the Intersect function and have it returned in the regions pop-up. This is what I have thus far, I think it's correct but it's not returning any values. I'm not getting any errors just no data returned. Can anyone see an issue with the expression or have an idea as to why nothing is being returned? 

Thanks for any help!

 

 

var lakes = Intersects($feature, FeatureSetById($map,"Lake_Report_CRCA_2021_4_9384"))
var lakes_list = ''
for (var f in lakes_list)
{
    lakes_list += f.OFFICIAL_N + TextFormatting.NewLine
}
return lakes_list

 

 

 

0 Kudos
1 Solution

Accepted Solutions
cpenling
New Contributor III

Found the problem. My for loop referenced lakes_list when it should be the lakes variable. I decided to use the Contains function instead of Intersects. Thanks for the help!

var lakes = Contains($feature,FeatureSetByName($map,"Lake Report 2021"))
var lakes_list = []
for (var f in lakes){
    Push(lakes_list, f.OFFICIAL_N)
    
}
return Concatenate(lakes_list, '\n')

 

View solution in original post

5 Replies
jcarlson
MVP Esteemed Contributor

No ideas why nothing's being returned, but a suggestion:

Create an array to hold your lake values, then use Concatenate to format your output string. Keeps from having an extra newline character when there's only one value.

var lakes_list = []

for (var f in lakes_list){
    Push(lakes_list, f.OFFICIAL_N)
}

return Concatenate(lakes_list, '\n')
- Josh Carlson
Kendall County GIS
KenBuja
MVP Esteemed Contributor

I'm surprised it didn't show an error on this line, which misspelled "TextFormatting.NewLine"

lakes_list += f.OFFICIAL_N + TestFormatting.NewLine

 

cpenling
New Contributor III

It is weird that didn't produce an error. I fixed it but it still doesn't return anything... I tried to use Count on the lakes variable and got an execution error. 

0 Kudos
cpenling
New Contributor III

Found the problem. My for loop referenced lakes_list when it should be the lakes variable. I decided to use the Contains function instead of Intersects. Thanks for the help!

var lakes = Contains($feature,FeatureSetByName($map,"Lake Report 2021"))
var lakes_list = []
for (var f in lakes){
    Push(lakes_list, f.OFFICIAL_N)
    
}
return Concatenate(lakes_list, '\n')

 

ClaudiaGIS
New Contributor III

Hello, I was able to do an intersect of the layers using Arcade and I am able to see the expression value in my pop-up. Is there a way to take this expression into a dashboard? I am just trying to show the value in a list. Thank you.