I'm trying to create an arcade intersect expression for attribute rule in arcgis pro which will populate the attribute field 'Habitat_SiteName' in my Habitat_Patches layer when I create new polygons. The underlying polygon field name in the Habitat_Polygons layer is 'SiteName', within a file geodatabase.
Feature class 1: Habitat_Patches
Feature class 2: Habitat_Polygons
Triggers I would like to use are Insert and update.
Solved! Go to Solution.
// load the habitat polygons
var habitats = FeaturesetByName($datastore, "Habitat_Polygons")
// get the first intersecting habitat
var habitat = First(Intersects(habitats, $feature))
// no intersecting habitat? -> abort
if(habitat == null) { return null }
// else return the habitat's site name
return habitat.SiteName
In that case, you would leave the field parameter empty and return a dictionary instead of a value.
var habitats = FeaturesetByName($datastore, "Habitat_Polygons")
var habitat = First(Intersects(habitats, $feature))
if(habitat == null) { return null }
return {
"result": { "attributes": {
"Field1": habitat.Field1,
"Field2": habitat.Field2
}}
}
// load the habitat polygons
var habitats = FeaturesetByName($datastore, "Habitat_Polygons")
// get the first intersecting habitat
var habitat = First(Intersects(habitats, $feature))
// no intersecting habitat? -> abort
if(habitat == null) { return null }
// else return the habitat's site name
return habitat.SiteName
Thanks Johannes, that worked a treat. sorry another question im trying to get my head around arcade. How would it work if you had multiple fields to copy.
In that case, you would leave the field parameter empty and return a dictionary instead of a value.
var habitats = FeaturesetByName($datastore, "Habitat_Polygons")
var habitat = First(Intersects(habitats, $feature))
if(habitat == null) { return null }
return {
"result": { "attributes": {
"Field1": habitat.Field1,
"Field2": habitat.Field2
}}
}
Thanks again Johannes, the link was really helpful and will have a play with the other options.
Have a great day too
Kazzie