Arcade within() function; points within polygon

194
2
Jump to solution
a month ago
TylerT
by
Occasional Contributor III

Hello,

I have two feature classes, one point feature class, and one polygon feature class.  When a point falls within a polygon I would like to symbolize differently than a point that is not within a polygon.  Does anyone have an example arcade expression to accomplish this?  Thank you.

Tyler

ArcGIS Pro 3.2.0

0 Kudos
1 Solution

Accepted Solutions
AlfredBaldenweck
MVP Regular Contributor

So... This is an expression that is actually pretty simple in theory.

This expression works fine for popups.

var wit = FeatureSetByName($datastore, "poly")
var check = (Within($feature, wit))
if (check == true){
    return "Inside"
}
else {
    return "Outside"
}

 

The problem that makes this currently impossible is that $featureset is not available for Symbology or Labeling.

When will Arcade get more useful, esp with Feature... - Esri Community

Basically, because it's designed to execute on a feature-by-feature basis, a call is made to wherever the data lives for every. single. feature. instead of just loading the featureset into memory or caching it in the map.

To avoid it being super slow, we instead only get to reference featuresets for popups, since you can only Identify a few features at a time. (And this is still really slow: See @jcarlson's blog post for tips to improve $featureset stuff Improving Expression Performance: A Custom Functio... - Esri Community)

 

Long story short: Should be very easy, is currently impossible due to technical limitations.

As an alternative, if your data lives in an enterprise geodatabase, you could use a query layer or a view to return a computed column detailing if the points are "within" and then symbolize off of that.

 

View solution in original post

2 Replies
AlfredBaldenweck
MVP Regular Contributor

So... This is an expression that is actually pretty simple in theory.

This expression works fine for popups.

var wit = FeatureSetByName($datastore, "poly")
var check = (Within($feature, wit))
if (check == true){
    return "Inside"
}
else {
    return "Outside"
}

 

The problem that makes this currently impossible is that $featureset is not available for Symbology or Labeling.

When will Arcade get more useful, esp with Feature... - Esri Community

Basically, because it's designed to execute on a feature-by-feature basis, a call is made to wherever the data lives for every. single. feature. instead of just loading the featureset into memory or caching it in the map.

To avoid it being super slow, we instead only get to reference featuresets for popups, since you can only Identify a few features at a time. (And this is still really slow: See @jcarlson's blog post for tips to improve $featureset stuff Improving Expression Performance: A Custom Functio... - Esri Community)

 

Long story short: Should be very easy, is currently impossible due to technical limitations.

As an alternative, if your data lives in an enterprise geodatabase, you could use a query layer or a view to return a computed column detailing if the points are "within" and then symbolize off of that.

 

TylerT
by
Occasional Contributor III

@AlfredBaldenweck 
Interesting.  I guess that might explain why I was getting errors with my Arcade attempts.  Thank you.

Tyler

0 Kudos