Arcade Expression (Intersect two polygons layers)

3383
7
Jump to solution
09-17-2021 12:22 AM
Greta
by
New Contributor III

HI I want to write an Arcade expression in a pop up. 

I have two polygon layers in my web map

Suburb polygon and Flood polygon

I want to appear the name of the suburb in the flood event pop up  when click on the suburb layer 

My expression is

var SI = FeatureSetByName($map,"Suburb")
var int = First(Intersects($feature, SI))
return int.Suburb

The expression returns a suburb name but it returns the same name all the time for example "suburb 1". If I click in another suburb it still  return the name "suburb 1" 

 

 

 

0 Kudos
2 Solutions

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi @Greta 

When you click on the flood area you want to see the suburb at the location where you clicked. The problem is that when you start with the flood area polygon it will use the entire polygon to see what suburbs it intersects with and when your flood area polygon is large it will intersect with a large number of suburbs. At this moment it is not possible in the Arcade expression to have access to the location where the user clicked and therewith being able to return a single suburb at the location. You will have in the pop-up a button to go through all the features at the location where the user clicked and have access to the suburb, but not as you want in the pop-up of the flood area:

XanderBakker_0-1632404038091.png

You could also go a little further and present information of multiple suburbs and the % of the area that the flood area covers the suburb. There are many possibilities. 

I have created an idea to provide access to the location clicked, but it is not implemented yet. Hopefully, this will happen soon. 

View solution in original post

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hoi @Ade_Bruijn ,

Your expression is close, but when you intersect the "wijken" layer with a "buurt", you obtain a featureset or in other words a collection of features even if there is only one feature. You will have to take for instance the first wijk found and then you can access the attribute that contains the name fo the "wijk". 

var wijken = FeatureSetById($map, /* concept wijken(afgeleid_van_buurten) */ "CBS_wijken_afgeleid_van_buurten__3310");
var wijk = First(Intersects(wijken, $feature));
return wijk["VeldNaamVanVeldMetWijkNaam"];

 

There is a potential catch... it is possible that a neighboring "wijk" is also returned and to avoid obtaining the wrong "wijk" name you could do a negative buffer to reduce the size of the "buurt" (current feature)  and ensure that you get the right "wijk". An example you can find below:

var wijken = FeatureSetById($map, /* concept wijken(afgeleid_van_buurten) */ "CBS_wijken_afgeleid_van_buurten__3310");
var buf = Buffer($feature, -1, "meter");
var wijk = First(Intersects(wijken, buf));
return wijk["VeldNaamVanVeldMetWijkNaam"];

View solution in original post

7 Replies
XanderBakker
Esri Esteemed Contributor

Hi @Greta 

When you click on the flood area you want to see the suburb at the location where you clicked. The problem is that when you start with the flood area polygon it will use the entire polygon to see what suburbs it intersects with and when your flood area polygon is large it will intersect with a large number of suburbs. At this moment it is not possible in the Arcade expression to have access to the location where the user clicked and therewith being able to return a single suburb at the location. You will have in the pop-up a button to go through all the features at the location where the user clicked and have access to the suburb, but not as you want in the pop-up of the flood area:

XanderBakker_0-1632404038091.png

You could also go a little further and present information of multiple suburbs and the % of the area that the flood area covers the suburb. There are many possibilities. 

I have created an idea to provide access to the location clicked, but it is not implemented yet. Hopefully, this will happen soon. 

0 Kudos
CBarrett
New Contributor II

Any chance you can link to this idea so I can give it my support?


I have created an idea to provide access to the location clicked, but it is not implemented yet. Hopefully, this will happen soon. 




XanderBakker
Esri Esteemed Contributor

Hi @CBarrett ,

 

Thanks for your support. You can find the link below: https://community.esri.com/t5/arcgis-online-internal-ideas/provide-the-location-clicked-in-the-pop-u... (although this is an internal idea, and it might not be available to everyone)...

0 Kudos
Greta
by
New Contributor III

Thank you

0 Kudos
Ade_Bruijn
New Contributor III

Hi,

I have a similar question but I'm not sure despite answer  @XanderBakker  if it's possible or not. So I will describe the case. Two polygon layers, one with districts (wijken) and the other with smaller polygons, neighbourhoods (buurten). I want the name of the district to apear in the popup of the neighbourhood. I tried several Arcade Geometry Functions Contains, Within and Intersects.

var wijken=FeatureSetById($map, /* concept wijken(afgeleid_van_buurten) */ "CBS_wijken_afgeleid_van_buurten__3310")
var wijk=Intersects(wijken,$feature)
return wijk

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hoi @Ade_Bruijn ,

Your expression is close, but when you intersect the "wijken" layer with a "buurt", you obtain a featureset or in other words a collection of features even if there is only one feature. You will have to take for instance the first wijk found and then you can access the attribute that contains the name fo the "wijk". 

var wijken = FeatureSetById($map, /* concept wijken(afgeleid_van_buurten) */ "CBS_wijken_afgeleid_van_buurten__3310");
var wijk = First(Intersects(wijken, $feature));
return wijk["VeldNaamVanVeldMetWijkNaam"];

 

There is a potential catch... it is possible that a neighboring "wijk" is also returned and to avoid obtaining the wrong "wijk" name you could do a negative buffer to reduce the size of the "buurt" (current feature)  and ensure that you get the right "wijk". An example you can find below:

var wijken = FeatureSetById($map, /* concept wijken(afgeleid_van_buurten) */ "CBS_wijken_afgeleid_van_buurten__3310");
var buf = Buffer($feature, -1, "meter");
var wijk = First(Intersects(wijken, buf));
return wijk["VeldNaamVanVeldMetWijkNaam"];
Ade_Bruijn
New Contributor III

Thank you @XanderBakker ,

Exactly what I wanted to achieve. And of course I needed also the negative buffer. Simple but effective trick.

Groeten Anne

0 Kudos