Select to view content in your preferred language

Arcade Question: Intersect two polygon layers in pop-up

573
2
Jump to solution
07-19-2023 11:21 AM
MelanieBass
New Contributor III

I am trying to write an arcade script on my pop-up for parcel. I have three polygon layers that represent 'Water Service Area", "Sewer Service Area", and "Reclaimed Service Area". I want to write the Arcade script so that when I select on a specific parcel it will return saying that the Parcel is on Water, or Sewer, or Reclaimed. I thought I had figured the code out but when I click around on the map, every pop-up says the same thing. It is not specific to that parcel. Here is the code I wrote:

expression 1

var water= FeatureSetByName($map, "Water Service Area")
var Intersects = Intersects($feature, water)
return 'Water'
 
 expression 2
 
var sewer= FeatureSetByName($map, "Sewer Service Area")
var Intersects = First(Intersects($feature, sewer))
return 'Sewer'
 
expression 3 
var reclaim= FeatureSetByName($map, "Reclaimed Water Service Area")
var Intersects = Intersects($feature, reclaim)
return 'Reclaimed Water'
 
So for the pop-up I had 

Parcel: {PARCEL} 

This parcel is on City:

{expression/expr0} 

{expression/expr1} 

{expression/expr2} 

 

I was reading old posts that maybe what I am trying to do is not possible. If someone has any advice or a work around that would be great.

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

What you'll have to do is check to see if an Intersection returns a feature for each of different layers. Or you could assume that a parcel would be in one of the three layers and only check the first two.

This script checks whether the feature intersects with the Water layer. If not, then it checks the Sewer area. If that doesn't return anything, it assumes it's in the Reclaimed area.

 

var water= FeatureSetByName($map, 'Water Service Area')
var WIntersects = Intersects($feature, water);
If (Count(WIntersects) > 0) return 'Water';
var sewer= FeatureSetByName($map, 'Sewer Service Area')
var sIntersects = First(Intersects($feature, sewer))
if (Count(sIntersects) > 0) return 'Sewer';
return 'Reclaimed Water';

 

One note. You shouldn't use a variable name that is a reserved word (like the function Intersects)

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

What you'll have to do is check to see if an Intersection returns a feature for each of different layers. Or you could assume that a parcel would be in one of the three layers and only check the first two.

This script checks whether the feature intersects with the Water layer. If not, then it checks the Sewer area. If that doesn't return anything, it assumes it's in the Reclaimed area.

 

var water= FeatureSetByName($map, 'Water Service Area')
var WIntersects = Intersects($feature, water);
If (Count(WIntersects) > 0) return 'Water';
var sewer= FeatureSetByName($map, 'Sewer Service Area')
var sIntersects = First(Intersects($feature, sewer))
if (Count(sIntersects) > 0) return 'Sewer';
return 'Reclaimed Water';

 

One note. You shouldn't use a variable name that is a reserved word (like the function Intersects)

0 Kudos
MelanieBass
New Contributor III

Thank you very much! So I couldn't use this all in one expression as you have it written but what I did is split out the very first part of the expression. 

var sewer= FeatureSetByName($map, 'Sewer Service Area')
var sIntersects = Intersects($feature, sewer);
If (Count(sIntersects)> 0) return 'Sewer';
 
Then next expression 
var reclaim = FeatureSetByName($map, 'Reclaimed Water Service Area')
var rIntersects = (Intersects($feature, reclaim))
if (Count(rIntersects)> 0) return 'Reclaimed Water'
 
Last expression
var water= FeatureSetByName($map, 'Water Service Area')
var WIntersects = Intersects($feature, water);
If (Count(WIntersects) > 0) return 'Water';
 
This was my pop-up

Parcel: {PARCEL} 

This parcel is on City:

{expression/expr3} 

{expression/expr4} 

{expression/expr5} 

So when I ran the entire expression, it only read the first part of the expression then stopped. So when I clicked on an area that didn't have sewer for instance with whole script it returned blank. I hope this makes sense. I wrote all this out just in case someone else needs assistance with Intersect function. 

 

Thanks again.

0 Kudos