Select to view content in your preferred language

Boolean Value from Intersects in Arcade

1759
5
Jump to solution
02-11-2022 09:57 AM
Labels (1)
PeterDalrymple
Regular Contributor

Hi all,

Can anyone provide any examples or an explanation of how to get a Boolean output rather than a FeatureSet output from the Intersects() or Within() functions? The documentation doesn't elaborate much on this and states that the function provides a Boolean output. The goal for me would be to get an Boolean value for the spatial relationship between features without having to use the Count() function as is shown in many other posts. 

For example, I would think this expression would work, but it doesn't.

 

IIF(Intersects(geom1, geom2), "In", "Out")

 

Neither does this (always returns false):

 

var myValue = Intersects(geom1, geom2)

IIF(myvalue == true, "In", "Out")

 

If I cast the intersects output as a Boolean, it is always false.

 

IIF(Boolean(Intersects(geom1, geom2)), "In", "Out")

 

There are a couple other expression patterns I've tried, but the only thing that works is to count the number of features returned in the FeatureSet and return values based upon the number of features returned.

I have met with a few people recently who had the same issue so it seems like a fairly common question.

Thanks in advance!

Peter

1 Solution

Accepted Solutions
KimGarbade
Frequent Contributor

Finally got it to work in a popup.  I tried 15 ways and it finally worked when I returned a single feature and used the feature's geometry.

This is code in a popup  

KimGarbade_0-1644611743664.png

KimGarbade_1-1644611986407.png

KimGarbade_2-1644612038441.png

 

 

 

View solution in original post

5 Replies
KristinJ
Occasional Contributor

I too have recently encountered this with the Within fucntion returning a feature set and not a boolean as expected from the documentation:

KristinJudy_0-1644604807219.png

KristinJudy_1-1644604818329.png

Some input from Esri on this would be much appreciated.

HuubZwart
Frequent Contributor

Note Intersects return a featureset instead of a boolean if a featureset is the input of parameter 1. See documentation here . To output a boolean you would need to input a geometry. I cannot tell how geom1 is constructed for @PeterDalrymple , but FeatureSetById in your example definitely returns a featureset and will hence return a featureset as well when used as input for Intersects

0 Kudos
PeterDalrymple
Regular Contributor

Hi @HuubZwart , thanks for your response! Is this what you're referring to? This is still returning a FeatureSet object for me. 

GeomConst.JPG

Thanks again!

Peter

 

0 Kudos
KimGarbade
Frequent Contributor

Finally got it to work in a popup.  I tried 15 ways and it finally worked when I returned a single feature and used the feature's geometry.

This is code in a popup  

KimGarbade_0-1644611743664.png

KimGarbade_1-1644611986407.png

KimGarbade_2-1644612038441.png

 

 

 

PeterDalrymple
Regular Contributor

That's interesting @KimGarbade ,

Glad you got that to work! That also worked for me. Wondering if the issue on my side may have been that the polygon layer I'm using has multiple polygon features. Even though it is filtered to only one polygon feature in the map, you must still have to query for the specific feature to use for the intersect?

GeomConst2.JPG

Thanks!

Peter 

 

0 Kudos