Arcade Label - Filter using a different layer

1391
7
05-05-2021 09:01 AM
Labels (1)
RickeyFight
MVP Regular Contributor

I am trying to label streets on a map. I want only streets that are within a the polygon layer to display. 

Is there a way to do this with arcade or is another way better?  

RickeyFight_0-1620230263541.png

 

0 Kudos
7 Replies
jcarlson
MVP Esteemed Contributor
var portal = Portal('https://www.arcgis.com');
var aoi = FeatureSetByPortalItem(portal, 'polygon_itemid', 0);

if(Intersects($feature, aoi)){
    return $feature.label_field
}

 

That might grab features that are along the edge or barely touch it. You could apply a negative buffer on the polygon, or change Intersects to Within, if you get too many "edge" features labelled.

- Josh Carlson
Kendall County GIS
0 Kudos
RickeyFight
MVP Regular Contributor

@jcarlson Thank you for the quick reply. 

I am not using portal so I cannot use var portal.   Is there a way to identify another layer in pro arcade. 

0 Kudos
jcarlson
MVP Esteemed Contributor

Try FeatureSetByName, maybe? That would look like this:

var aoi = FeatureSetByName($map, 'polygon_layername');

if(Intersects($feature, aoi)){
    return $feature.label_field
}
- Josh Carlson
Kendall County GIS
0 Kudos
RickeyFight
MVP Regular Contributor

@jcarlson 

I am getting this error. 

RickeyFight_0-1620235628514.png

 

0 Kudos
jcarlson
MVP Esteemed Contributor

Oh, shoot. I forgot that using FeatureSetBy... functions is not available in the labeling Arcade profile. My mistake.

Everything else I can find will eliminate labels within a polygon, but not the inverse. Is the polygon layer something you can modify? If you turned it into a giant "donut", with the current shape being the "hole", you could use the Label Weight Ranking settings to exclude labels within that area.

jcarlson_0-1620236268300.png

 

- Josh Carlson
Kendall County GIS
RickeyFight
MVP Regular Contributor

@jcarlson Yes I can modify the polygon layer. If I cannot find anything else I will try that. Thanks! 

 

0 Kudos
LindaWilliams1
Occasional Contributor

Another way would be to clip your streets layer by your polygon, set this street symbol to no color, and then label this street layer rather than the one that extends beyond the polygon.