Auto populate attribute field from intersecting feature (polygon field to point field)

1057
9
Jump to solution
08-19-2021 10:38 PM
BDU_RyanChittenden
New Contributor III

Hi, I am using attribute rule to auto populate an attribute field from a polygon feature to an attribute field in a point feature.

I have suppression repair points with an empty "DPA_AGENCY" Field and a polygon feature that contains the "DPA_AGENCY" information which I want the point "DPA_AGENCY" field to grab from.  I've looked up Arcade expressions and I am not even sure I have the right one.

The feature "Suppression_repair_points" the attribute field "DPA_AGENCY"

"Direct_Protection_areas" is the feature I wish to pull info from the "DPA_AGENCY" field

ESRI attribute rule example:

attribute_rule.JPG

 

0 Kudos
1 Solution

Accepted Solutions
BDU_RyanChittenden
New Contributor III

var zones = FeatureSetByName($datastore,"DirectProtectionAreas21",["DPA_GROUP"],true)

var intersectingZones = Intersects(zones, Geometry($feature))

var matchedZone = First(intersectingZones)

return IIf(IsEmpty(matchedZone), null, matchedZone.DPA_GROUP);

View solution in original post

0 Kudos
9 Replies
JohannesLindner
MVP Regular Contributor

You found a quite complicated example 🙂

// Calculation rule
// Suppression_repair_points, field DPA_AGENCY
// Triggers: Insert, Update

// optional:
// if DPA_AGENCY is already filled, just return its value (do nothing)
//if(!IsEmpty($feature.DPA_AGENCY)) {
//  return $feature.DPA_AGENCY
//}

// load the polygon fc
var dpa_fc = FeatureSetByName($datastore, "database.dataowner.DirectProtection_areas")

// intersect the feature with the polyons
var dpa_inter = Intersects(dpa_fc, $feature)

// if the feature doesn't intersect a dpa polygon, return null
if(dpa_inter == null || Count(dpa_inter) == 0) {
  return null
}

// grab the first intersecting polygon and return its DPA_AGENCY value
return First(dpa_inter).DPA_AGENCY

Have a great day!
Johannes
0 Kudos
BDU_RyanChittenden
New Contributor III

Thank you!  Still receiving an error though.

attribute_rule_error.JPG

0 Kudos
JohannesLindner
MVP Regular Contributor

FeatureSetByName needs the complete name of the feature class.

If you're in a file geodatabase, thats probably just the name of the feature class (DirectProtectionAreas21_2).

If you're in an Enterprise geodatabase, the full name is "DatabaseName.DataownerName.DirectProtectionAreas21_2", where you have to replace DatabaseName and DataownerName.

Browse to the feature class in the catalog to see its full name:

JohannesLindner_0-1629440954628.png

 


Have a great day!
Johannes
0 Kudos
BDU_RyanChittenden
New Contributor III

it's a file geodatabase.

So I'd replace: "database.dataowner.DirectProtectionAreas21_2"

with: "DatabaseName.DataownerName.DirectProtectionAreas21_2"

Capture.JPG

0 Kudos
JohannesLindner
MVP Regular Contributor
var dpa_fc = FeatureSetByName($datastore, "DirectProtectionAreas21_2")

Have a great day!
Johannes
0 Kudos
BDU_RyanChittenden
New Contributor III

What is dpa_inter and dpa_fc?

0 Kudos
BDU_RyanChittenden
New Contributor III

expression valid this time but:  ERROR 002717: Invalid Arcade expression, Arcade error: Table not found DirectProtectionAreas21_2, Script line: 12 [DirectProtectionAreas21_2]
Failed to execute (AddAttributeRule).

 

// Calculation rule
// Suppression_repair_points, field DPA_AGENCY
// Triggers: Insert, Update

// optional:
// if DPA_AGENCY is already filled, just return its value (do nothing)
//if(!IsEmpty($feature.DPA_AGENCY)) {
// return $feature.DPA_AGENCY
//}

// load the polygon fc
var dpa_fc = FeatureSetByName($datastore, "DirectProtectionAreas21_2")

// intersect the feature with the polyons
var dpa_inter = Intersects(dpa_fc, $feature)

// if the feature doesn't intersect a dpa polygon, return null
if(dpa_inter == null || Count(dpa_inter) == 0) {
return null
}

// grab the first intersecting polygon and return its DPA_AGENCY value
return First(dpa_inter).DPA_AGENCY


0 Kudos
BDU_RyanChittenden
New Contributor III

ERROR: INVALID EXPRESSION  ERROR ON LINE 12  Table not found DirectProtectionAreas21_2

 

// Calculation rule
// Suppression_repair_points, field DPA_AGENCY
// Triggers: Insert, Update

// optional:
// if DPA_AGENCY is already filled, just return its value (do nothing)
//if(!IsEmpty($feature.DPA_AGENCY)) {
// return $feature.DPA_AGENCY
//}

// load the polygon fc
var dpa_fc = FeatureSetByName($datastore, "database.dataowner.DirectProtection_areas")

// intersect the feature with the polyons
var dpa_inter = Intersects(dpa_fc, $feature)

// if the feature doesn't intersect a dpa polygon, return null
if(dpa_inter == null || Count(dpa_inter) == 0) {
return null
}

// grab the first intersecting polygon and return its DPA_AGENCY value
return First(dpa_inter).DPA_AGENCY

0 Kudos
BDU_RyanChittenden
New Contributor III

var zones = FeatureSetByName($datastore,"DirectProtectionAreas21",["DPA_GROUP"],true)

var intersectingZones = Intersects(zones, Geometry($feature))

var matchedZone = First(intersectingZones)

return IIf(IsEmpty(matchedZone), null, matchedZone.DPA_GROUP);

0 Kudos