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
Solved! Go to Solution.
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
I too have recently encountered this with the Within fucntion returning a feature set and not a boolean as expected from the documentation:
Some input from Esri on this would be much appreciated.
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
Hi @HuubZwart , thanks for your response! Is this what you're referring to? This is still returning a FeatureSet object for me.
Thanks again!
Peter
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
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?
Thanks!
Peter