Select to view content in your preferred language

Using Attribute Rules to calculate fields from intersecting polygons

7144
14
Jump to solution
03-04-2021 09:05 AM
TINATHOMPSON
Emerging Contributor

We have recently made the move to ArcGIS Pro for everything except our 911 Addressing.  We are searching for an Attribute rule that would allow us to take attribute data from several polygon layers and put them into our address layer.  In other words, we want to enter a new address point and have the attribute rule to go out and find certain data (ESN, Community, Senate, House, JP District, etc.) and enter that into our Address layer.  We were able to do this in ArcGIS Desktop using a script but that script will not work in Attribute rules.  Unfortunately, I do not understand Arcade and I'm pretty limited with vbscript.  I'm hoping that there is someone out there that has built something like this that would share it with me.

 

Thank You all in advance.

0 Kudos
1 Solution

Accepted Solutions
JoeBorgione
MVP Emeritus

The trick with getting values from underlying polygon features is those features have to reside in the same "datastore" as your points.  The datastore is nothing more than than the database, be it FGDB or EGDB that holds your data. It's a limitation of Arcade.  However, here is a rule that I apply to get underlying zip code onto a site address point: 

 

var zip = FeatureSetByName($datastore,"MSD.SLCOMSD.ZipcodesMSD",["ZIP_MOD_ID"], true)
var intersectLayer = Intersects(zip, Geometry($feature))
if (Count(intersectLayer) > 0) {
    var layer = First(intersectLayer);
    return layer.ZIP_MOD_ID;    
} else {
    return null;
}

 

Here I'm extracting the value of the field ZIP_MOD_ID from the ZipcodesMSD layer in our SDE database.  The if statement makes sure there is an intersecting layer to the point; @XanderBakker guided me through this one so all my intersecting rules check for that first.

 

 

That should just about do it....

View solution in original post

14 Replies
AlexRodriguez
Regular Contributor

I'm assuming the script you had running while using Desktop was a PYTHON script.  That being the case, why can't you run that same script in PRO?   Import that script to your toolbox and run it.

 

XanderBakker
Esri Esteemed Contributor

Hi @TINATHOMPSON ,

@AlexRodriguez  has a valid point. If you have a Python script that worked in ArcMap chances are high that it will work in  Pro too (maybe with some slight modifications). A potential downside could be that you need to create some sort of trigger to execute the script to update the data when changes are made. You can work with scheduled tasks in Pro.

Now, using attribute rules may have the advantage that updating the data will trigger the attribute rule and update the data so you will always look at updated information and are not depending on a manual or scheduled update. It will require you to rewrite the code, your data must reside in the same data store and they must have GlobalIDs...

JoeBorgione
MVP Emeritus

@TINATHOMPSON  check this blog.  I don't work in 9-1-1 anymore but I still do addressing and I use the ESRI Address Data Management Solution.  I augmented the solution with a couple of my own rules that grab underlying polygon data to populate address points.  I really like the solution for addressing, but will be the first to tell you that the Arcade portion can be a challenge; but that's what this forum is for. Just ask @XanderBakker how many times he helped me out...

That should just about do it....
0 Kudos
TINATHOMPSON
Emerging Contributor
Joe,
I have looked at the ESRI Address Data Management Solution in the past and took another look at it today. It is a nice tool but I don't see any attribute rules that would populate fields from polygon layers. That is where my problem is at, I can't figure out the Arcade script in order to make this work.
Thank you for your help and awesome job on your project!


Tina L. Thompson, CFM, GISP
GIS/911 Administrator
1109 S 16th St
Fort Smith, AR 72901
(479)785-2651
www.wapdd.org
www.wagis.org

Chairperson, River Valley GIS Users Group
www.rivervalleygisusers.org

Committee Member, GISCI Oversight Committee
Committee Member, APCO International Awards Committee
Committee Member, AR GIS Users Forum
Committee Member, National NENA 911/GIS Stewardship Working Group



0 Kudos
JoeBorgione
MVP Emeritus

The trick with getting values from underlying polygon features is those features have to reside in the same "datastore" as your points.  The datastore is nothing more than than the database, be it FGDB or EGDB that holds your data. It's a limitation of Arcade.  However, here is a rule that I apply to get underlying zip code onto a site address point: 

 

var zip = FeatureSetByName($datastore,"MSD.SLCOMSD.ZipcodesMSD",["ZIP_MOD_ID"], true)
var intersectLayer = Intersects(zip, Geometry($feature))
if (Count(intersectLayer) > 0) {
    var layer = First(intersectLayer);
    return layer.ZIP_MOD_ID;    
} else {
    return null;
}

 

Here I'm extracting the value of the field ZIP_MOD_ID from the ZipcodesMSD layer in our SDE database.  The if statement makes sure there is an intersecting layer to the point; @XanderBakker guided me through this one so all my intersecting rules check for that first.

 

 

That should just about do it....
TINATHOMPSON
Emerging Contributor

Thank you for your help.  I've been doing this for 30+ years, I'm ready to retire as well.  I have found the python script that we used to use and I'm going to try it, as well as possibly look at your solution.

XanderBakker
Esri Esteemed Contributor

Hi @JoeBorgione ,

Quick question... would you create multiple rules since the OP needs to update values from multiple layers or would you use a single attribute rule? If it is the latter, I suppose the return value should be changed to include multiple values. I was looking for an example of this and can't find any, but I suppose it should be similar to updating another feature layer, right?

0 Kudos
JoeBorgione
MVP Emeritus

Hey @XanderBakker ; for each layer I have a rule.  I did it that way because each layer has a value for a different field in my site address points: 

Municipalities layer provides a city name for the point field CITY

Zip code layer provides  a numeric zipcode value for the point field ZipCode

etc...  For a 9-1-1 application there would be feature layers like PoliceBeat, FireZone, EMTZone etc...

I don't know how to construct a single attribute rule for multiple attributes.

That should just about do it....
XanderBakker
Esri Esteemed Contributor

Hi @JoeBorgione ,

Thanks for getting back. It makes sense what you are saying. I think it should be possible to return multiple values in a single Attribute Rule, but I haven't seen examples of this. I do suppose that it follows the same logic as the "Edit another feature class with a calculation rule" example here: https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/attribute-rule-script-expre... 

(but I am not sure)