Chasing my tail with Arcade/Attribute Rules

2463
10
Jump to solution
03-23-2020 10:08 AM
JoeBorgione
MVP Emeritus

I am testing the feasibility of the Address Management Solution for my agency.  There are a number of attribute rules embedded upon the feature classes that populate fields upon editing.  For example, the site address point feature class concatenates address elements (pre dir, house num, street name etc) into the full address field.  Easy enough.

However, I'd like to populate attributes based on spatial location: add a new point and be able to populate city and zip from underlying coincident polygons: if the new point falls within the city of Holladay (municipality layer) and 84124 (zip code layer) I want the appropriate fields in the point populated.

I've done this sort of thing using attribute assistant, and I could make the calculations using arcpy, but with Arcade the scripting language of choice for Attributes Rules, I'm wallowing in the trough of the the learning curve.

That should just about do it....
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

Hey Joe,

I was able to get this to work.  I tested adding a county name to a point feature.  The county name is stored in a field called NAME.  The county feature class is in the same geodatabase as the point feature class, and the feature class is named Counties.  Here was the expression I used:

var countyBoundary =  FeatureSetByName($datastore, "Counties", ["NAME"], true)
var intersectLayer = Intersects(countyBoundary, Geometry($feature))
var layer = First (intersectLayer)
return layer.NAME

View solution in original post

10 Replies
JakeSkinner
Esri Esteemed Contributor

Hey Joe,

I haven't used Attribute Rules, but take a look at the following blog on how to do this using Arcade in a web map:

https://community.esri.com/community/gis/web-gis/arcgisonline/blog/2018/12/10/overlapping-features-i... 

This may give you the correct expression you're looking for.

0 Kudos
JoeBorgione
MVP Emeritus

Thanks Jake; I've got a Pro project open right now following along what Kelly Gerrow‌ describes.  There is also a blog entry by Xander Bakker‌ I'll follow along too.  These are giving me exposure to the Arcade logic.

That should just about do it....
0 Kudos
DanPatterson_Retired
MVP Emeritus

 Arcade ehh? couple of years to go Joe

JoeBorgione
MVP Emeritus

I'm hoping!

That should just about do it....
0 Kudos
JakeSkinner
Esri Esteemed Contributor

Hey Joe,

I was able to get this to work.  I tested adding a county name to a point feature.  The county name is stored in a field called NAME.  The county feature class is in the same geodatabase as the point feature class, and the feature class is named Counties.  Here was the expression I used:

var countyBoundary =  FeatureSetByName($datastore, "Counties", ["NAME"], true)
var intersectLayer = Intersects(countyBoundary, Geometry($feature))
var layer = First (intersectLayer)
return layer.NAME
JoeBorgione
MVP Emeritus

Awesome! Thanks Jake!  I'm right in the middle of not only the covid19 mojo like everyone else, but we had a significant earthquake here in the Salt Lake Valley; I'm working from home doing damage assessment database work and I'm getting tugged in multiple directions at once.  I think that's new normal. 

At any rate, I'll give your suggestion a try asap!

That should just about do it....
0 Kudos
JoeBorgione
MVP Emeritus

I was able to get the suggested code from Jake Skinner‌ to work, but I have a question regarding FeatureSetByName() function.  I had several different data sources in my ArcGIS Pro map and tried to use $map instead of $datastore and that failed with an error to the effect that $map was not defined.

As I understand it, if one uses $datastore, all the layers one is working with need to be in the same location so for testing  I have my points and my municipalities in the same local file gdb; I can now calculate the city name on a new point. Does $map not work in ArcGis Pro 2.5?  I'm going to be adding points and right now I don't know where all the layers that I need to use will be coming from, but I'm pretty sure I don't want them in the same Egdb as my address points.

Kelly Gerrow

Xander Bakker

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

Hi Joe Borgione , 

$map works in ArcGIS Pro 2.5, but it won't work in Arcade expressions used for Attribute Rules and Field Calculations (and others). Have a look at Profiles | ArcGIS for Developers  which lists all the available profiles where you can apply Arcade expressions and each profile has a table with the Globals that are available in that profile.

JoeBorgione
MVP Emeritus

That's an unfortunate limitation.  It seems to me that with services being exploited as data sources, logically we would want $map to work in Pro for calculations and/or attribute rules.  Time for an idea's post....

That should just about do it....
0 Kudos