Select to view content in your preferred language

Reference a layer in map using Arcade

73
4
yesterday
Justin_CLT
New Contributor II

I'm trying to write a field calculation expression in Arcade that will populate a value in the field of a point feature using a value from the intersecting polygon from another feature class in the same map. The documentation I've seen shows to reference a layer in the same map using either $map or $layer. I've tried both of the lines below, but neither are working and give me an object not found error.

 

var dem = FeatureSetByName($map, “Elev_Polygons_2023”, “FieldName = ‘gridcode’”);

var dem = FeatureSetByName($layer, “Elev_Polygons_2023”, “FieldName = ‘gridcode’”);

 

Here is the full expression so far:

// Reference the current device feature

var device = $feature;

 

// Retrieve the DEM polygons feature set

var demFeatures = FeatureSetByName($layer, "Elev_Polygons_2023", ["gridcode"], true);

 

// Find the polygons that intersect with the current device

var intersectingPolygons = Filter(demFeatures, 'Intersects($feature)');

 

// Get the first intersecting polygon

var intersectingPolygon = First(intersectingPolygons);

 

// Extract the gridcode value if an intersecting polygon exists

var elevation = intersectingPolygon["gridcode"];

 

// Return the elevation value

return elevation;

0 Kudos
4 Replies
jcarlson
MVP Esteemed Contributor

Where are you trying to use this expression? Referencing other layers with Arcade functions a little differently in ArcGIS Pro compared to the web.

If the DEM polygons are a published service, I'd suggest using FeatureSetByPortalItem instead, as it will work regardless of whether the layer is present in the map, and works the same in Pro or the web.

- Josh Carlson
Kendall County GIS
0 Kudos
Justin_CLT
New Contributor II

I'm using it in a field calculation in Pro. The Elev_Polygons_2023 feature class is in a file geodatabase.

0 Kudos
jcarlson
MVP Esteemed Contributor

Any chance the layers are in the same geodatabase? You could try using $datastore in the FeatureSetByName, rather than $layer or $map.

- Josh Carlson
Kendall County GIS
0 Kudos
Justin_CLT
New Contributor II

They are not in the same geodatabase.

0 Kudos