Select to view content in your preferred language

Calculate Field using Arcade expression

1961
3
04-10-2020 11:57 AM
CarylAlarcon
Emerging Contributor

How do you create an Arcade expression to reach out into other layers in the map to calculate values from another layer's features.  These are the names of two layers in a map 

EVER_FB_basinshorelines_Merge

USGS_GEOL_FloridaBayShoals  

EVER_FB_basinshorelines_Merge has an attribute field, "Island".

USGS_GEOL_FloridaBayShoals has an attribute field,  "Name". 

I would like to run the Calculate Field tool on "Island" to insert the values from "Name".  The features in the two layers intersect but are not in the same database.  What would I use for functions and syntax for the expression?

Thank you.

0 Kudos
3 Replies
RobertKrisher
Esri Regular Contributor

Unfortunately it looks like performing a field calculate across databases is not supported at this time, my guess is that Esri currently doesn't support this for performance reasons. You can double check this by looking at the arcade profile for the field calculate operation ( https://developers.arcgis.com/arcade/guide/profiles/#field-calculate ).

However, if you look closely at the profiles in Esri's help page (or the convienent table I put in my article https://www.powereng.com/insights/my-three-favorite-features-in-arcgis-q1-release-for-arcgis-profess... ) you can see that we do have access to the map profile in popups. If you did want to create a popup to do this you would configure the expression on your shoreline feature class and have it display the value from the shoal that it intersects with. This will involve using the featuresetbyname and intersects functions. The expression would look something like the following:

var all_features = FeatureSetByName($map,'USGS_GEOL_FloridaBayShoals', ['NAME'], true);
var coincident_features = Intersects(all_features, $feature)
First( coincident_features).NAME;

At that point any time you clicked a shoreline on the feature class, it would automatically display the corresponding island name. This may be good as a short term workaround, but in the long term you will likely need to use geoprocessing tools in order to do this calculation. Using model builder you would perform a spatial join between the layers, create a map join on the two layers in your map, and use a normal field calculate to set the value of the Shoal.Island to be the Shoreline.Name.

I look forward to the day that I can use Arcade to do these sorts of tasks, but unfortunately it's still working up to replacing the power of more traditional Geoprocessing tools.

CarylAlarcon
Emerging Contributor

Thank you.  

What if the two layers were in the same database?

Would the expression be the same?

0 Kudos
RobertKrisher
Esri Regular Contributor

Caryl,

  It should, with a relatively small modification.  The field calculate profile allows you to use the $datastore global variable, so if you replace the $map in the expression with $datastore then make sure all the field / class names are correct it should work.  Depending on how much data you are processing it may take a while (hundreds of features is fine).  These arcade expressions aren't as efficient at handling large datasets as geoprocessing tools, but they certainly are easier to get setup!

0 Kudos