Hi all,
I have two layers in my web map (districts & points). The points layer is coming from Survey123 feature layer.
I'd like to symbolize those features (in the district layer) based on the intersection with the points layer. (e.g. if intersects red and if doesn't green)
I can't access the attributes of the points layer from the styling Arcade expression of the districts' and creating FeatureSet isn't also available, unlike the Pop-ups.
Does anyone know how to do that or have any workaround?
P.S creating an S123 form based on the district layer and having both layers in one Hosted Feature Layer also didn't allow accessing.
This is one of the Community's "greatest hits", but one which, at the moment, has a very clear, disappointing answer: you can't.
Due to Arcade's different profiles, there are limitations in some contexts, but not others. In symbology in particular, you can't even access attributes of another feature in the same layer, let alone another layer entirely. You'd need the field "baked in" somehow in order to do this.
Have you considered publishing a hosted view layer of a join?
Hi Josh, thanks for your response.
That's sad!
I don't think I'll be able to use published views because the points layer is coming from a Survey123 form that captures the location (a text naming the district) of the points through an embedded JS code.
I'd probably need an alternative that's completely implemented on AGOL
You can have view layers in AGOL, but only if it's an attribute-based join, actually.
For a spatial relationship, you could use Arcade to calculate a new field, then just re-run the calculation regularly. It would be a simple enough expression that you could schedule a script or notebook to run automatically.
var other_features = FeatuerSetByPortalItem(
Portal('your portal url'),
'itemid of the service',
0, // or whatever layer index it happens to be
['fields', 'you', 'want'],
false
)
return Count(Intersects($feature, other_features)) > 0
This will return a "true" for features that intersect with those in another layer, "false" for those that do not.
Thanks, @jcarlson I'm not sure I understood what you mean by "..only if it's an attribute-based join". In fact, there's a mutual field between the two layers, would that help?
Thanks for sharing the code for the spatial relationship. I'll try it out.
Hi @jcarlson, I managed to create a python notebook with the below code and it works well in getting the intersecting polygon. However, I can't automate it using the ArcGIS Notebook Tasks to overwrite the output feature layer, despite including the Context ({"overwrite":"True"})...
from arcgis.gis import GIS
gis = GIS("home")
itemDis = gis.content.get("f464d940fd6................10d09")
itemDis
itemSrv = gis.content.get("306cb1..............489ec1ec")
itemSrv
from arcgis import features
intersectionLayer= features.summarize_data.join_features(target_layer=itemDis,
join_layer=itemSrv,
spatial_relationship='intersects',
output_name='all-clear-intersection',
context = {"overwrite": True})
Any idea how I can overwrite the output without failing the Notebook Tasks? The output layer will be used in dashboard and web app so I want to maintain using the same layer