Calculate Multiple Fields from multiple Intersection poly layers using Attribute Rules

473
3
Jump to solution
08-23-2022 12:13 PM
Labels (2)
JustinNettleton1
New Contributor III

I am setting up some attribute rules to populate fields in my NG911 address database.  A Lot of these fields are populated off of interests of 3 different polygon layers. I have them all set up as multiple rules now and they are working, but editing is very slow. 

I know I can combine these rules into one, just not sure how to do it when I am intersecting multiple layers to populate different fields. 

Can some one point me in the right direction or have a sample for me?

Thanks, 

Justin

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Basically, instead of choosing a field for the Attribute Rule and returning a value, you leave the field empty and return a dictionary. The possible keys of this dictionary are described here: https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/attribute-rule-dictionary-k...

var attribute_1 = null
var attribute_2 = null
var attribute_3 = "Nothing here"

var layer_1 = FeatureSetByName($datastore, "FC_1")
var id = $feature.SomeID
var polygon_1 = First(Filter(layer_1, "SomeID = @ID"))
if(polygon_1 != null) { attribute_1 = polygon_1.Attribute }

var layer_2 = FeatureSetByRelationshipName($feature, "Relationship")
var polygon_2 = First(layer_2)
if(polygon_2 != null) { attribute_2 = polygon_2.Attribute }

var layer_3 = FeatureSetByName($datastore, "FC_3")
var polygon_3 = First(Intersects($feature, layer_3))
if(polygon_3 != null) { attribute_3 = polygon_3.Attribute }

return {
    result: {
        attributes: {
            Attribute1: attribute_1,
            Attribute2: attribute_2,
            Attribute3: attribute_3,
        }
    }
}

 


Have a great day!
Johannes

View solution in original post

0 Kudos
3 Replies
JohannesLindner
MVP Frequent Contributor

Basically, instead of choosing a field for the Attribute Rule and returning a value, you leave the field empty and return a dictionary. The possible keys of this dictionary are described here: https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/attribute-rule-dictionary-k...

var attribute_1 = null
var attribute_2 = null
var attribute_3 = "Nothing here"

var layer_1 = FeatureSetByName($datastore, "FC_1")
var id = $feature.SomeID
var polygon_1 = First(Filter(layer_1, "SomeID = @ID"))
if(polygon_1 != null) { attribute_1 = polygon_1.Attribute }

var layer_2 = FeatureSetByRelationshipName($feature, "Relationship")
var polygon_2 = First(layer_2)
if(polygon_2 != null) { attribute_2 = polygon_2.Attribute }

var layer_3 = FeatureSetByName($datastore, "FC_3")
var polygon_3 = First(Intersects($feature, layer_3))
if(polygon_3 != null) { attribute_3 = polygon_3.Attribute }

return {
    result: {
        attributes: {
            Attribute1: attribute_1,
            Attribute2: attribute_2,
            Attribute3: attribute_3,
        }
    }
}

 


Have a great day!
Johannes
0 Kudos
JohannesLindner
MVP Frequent Contributor

Also, a lot of the slowness of Attribute Rules comes from the loading of FeatureSets. To make it quicker:

  • Load only the fields you need.
  • Don't load the geometries if you don't want to work with them. You can do an Intersects() without loading the geometry!

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

Thank you for these solutions. They have helped the performance. 

0 Kudos