Intersect arcade expressions for calculating fields and symbology based on intersects between two layers

4698
3
01-06-2021 10:43 AM
DataOfficer
Occasional Contributor III

Is there any way to calculate the field of an attribute table, or symbology based on an arcade expression for the intersect of two layers? A point layer and a polygon layer in this instance.

I am able to use an Intersects expression in a popup, e.g.:

// get the count for all sites in the grid

var sites = FeatureSetByName($map,"Sites")

var countSites = Count(Intersects(sites,$feature))

return countSites

 However the expressions available to calculate an attribute table field or symbology do not accept $map during the use of the FeatureSetByName function, giving the following error:

Execution Error:Runtime Error: Identifier Not Found. $map

Are there plans for this functionality to be supported in future?

3 Replies
XanderBakker
Esri Esteemed Contributor

Hi @DataOfficer ,

 

Q: Is there any way to calculate the field of an attribute table based on an arcade expression for the intersect of two layers?

A: Yes, if the data is stored in the same datastore and you are using $datastore in the Arcade expression ($map is not supported in the Field Calculation profile)

 

Q: Is there any way to define the symbology based on an arcade expression for the intersect of two layers?

A: No, the symbology profile does not provide access to other features and featuresets. You can however, calculate a field based on other features and featuresets and define the symbology on that newly created field.

 

DataOfficer
Occasional Contributor III

Hi @XanderBakker,
That's fantastic, thank you for the in-depth response. I will give it a try via the $datastore route.

0 Kudos
NedCake1
Occasional Contributor

Hi @XanderBakker and @DataOfficer 

Thanks for the $datastore recommendation it works perfectly!

Thought I'd leave a pic and some sample code for those that follow. I know it always helps me. The sample gets intersecting zip code values from a zip code layer (polygon) and calculates a Zip Code field for a law enforcement beats layer (polygon). If there is more than one intersecting zip code it will calculate the zip codes additional values with a coma separator. 

var intersectZIP = Intersects(FeatureSetByName($datastore,"Zip_Codes"),$Feature)
var zip = "";
for (var f in intersectZIP) {
    if (zip == "") {
        zip =(f.ZIPCODE);
    } else {
        zip += ", "+(f.ZIPCODE);            
    }
}
return zip;