ArcGIS pro Attribute Rules - Intersects

699
1
01-31-2022 06:05 AM
Labels (3)
MichaelDeliberato
New Contributor III

Good Morning!

After an Enterprise update we switched from using ArcGIS Attribute assistant to the new arcGIS pro Attribute Rules. I'm trying to adapt rules that we already had in attribute assistant into attribute rules. Admittedly, I'm working on strengthening my arcade but I feel like this should be easy so I'm not sure what I'm doing wrong and wanted to see if any of you fine people could help.

I'm working with a parcel fabric, but what I am trying to do is to do an intersect between a parcel that is new or edited, intersect that with a zip code layer that lies within the same map as the parcels, and return the zip code to the parcel. i have looked through a lot of the Esri documentation and have come up with the code below. but get an error when I try to implement it.

Current code i have in arcade is:


var geom2 = Polygon({ZipCodes});
first( Intersects($layer, geom2) );
Return Zipcodes.ZIPCODE

Am I missing something? it seems to be what i would think is easy but have had no luck yet. Thanks in advance with the help!

0 Kudos
1 Reply
jcarlson
MVP Esteemed Contributor

There are a few issues in the expression you've shared.

  • Polygon is for creating a single polygon feature from a JSON definition, and does not have other attributes. To get another layer of features that is not in your parcel fabric, you should use FeatureSetByPortalItem.
  • Calling First(Intersects(...)) will return something, but unless you store that result in a var, you have no way of further accessing its properties.
  • Attribute rules have a slightly different profile, and there is no "$map" global, so having the zip codes "in the same map" doesn't really matter.
  • Intersects needs at least one single feature as one of the parameters. Attribute rules fire at the feature level, so using "$feature" instead of "$layer" will work.

 

var portal = Portal('your-url')

var zips = FeatureSetByPortalItem(
    portal,
    'item-id-of-zips-layer',
    0, // Or whatever layer index your zips are in
    ['ZIPCODE'],
    true
)

var first_zip = First(Intersects($feature, zips))

return first_zip['ZIPCODE']

 

Also worth considering: if your parcels and zips don't align perfectly, there may be situations in which a tiny sliver of a zip code is caught by the intersection, and it mistakenly gets returned by first. If it's an issue, you can try something like taking the centroid of the feature before intersecting it with your zip codes.

- Josh Carlson
Kendall County GIS
0 Kudos