Attribute Rule for Location Description

1273
2
Jump to solution
03-25-2021 06:08 AM
James_Norquest
New Contributor II

Our organization is working on migrating to ArcGIS Pro and the new Utility Network. I am working on replicating Attribute Assistant functions with the new Attribute Rules in a test environment.

We have a location description field in all of our utility data that populates the nearest address when a feature is created. I am trying to replicate this function with Attribute rules. Attribute assistant based it on an address centerline file. I am trying to base it off situs points for my first try at the automation.

I am able to grab the nearest address but only one field. For some reason it wont concatenate. If I try to get is to return more than one field I get an error. I have tried concatenate in both the variable and results and about 50 other ridiculous ways to get it to work.

Here is the code that gives me the nearest "street" value. If I try to call and concatenate any other fields I get an error.

So I need the several fields from the intersected layer concatenated together to have a coherent address for my LOCDESC field

var situs_address = "street_name";

var feature_field = $feature.LOCDESC;

var address = featuresetbyname($datastore, 'situs');
//set some variables, tried to concatenate in var = situs_address, arcade does not like that//

var closest_address = first(intersects( address, Buffer($feature, 500, 'feet')));
// this is the meat and potatoes of the operation//

if (closest_address == null)
{
return $feature.locdesc;
}
if (isempty(closest_address.street_name))
{
return $feature[feature_field];
}
//takes care of the null values//

return closest_address[situs_address];
// tried all sorts of combinations here, tried adding variables for each feature i need and 
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Something like this?

return closest_address.street_name + " " + closest_address.house_number + ", " + closest_address.zip_code + " " + closest_address.town_name

 

Or for better readability:

var street = closest_address.street_name
var house = closest_address.house_number
var zip = closest_address.zip_code
var town = closest_address.town_name
return street + " " + house + ", " + zip + " " + town

 

I haven't figured out calling feature attributes by variables, yet:

// These work:
return $feature.Attribute
return $feature["Attribute"]

// This doesn't (in my experience):
var att = "Attribute"
return $feature[att]

// When working with features that aren't $feature (e.g. your closest_address), only this seems to work:
var f = First(Intersect(FeatureSetByName(...), $feature))
return f.Attribute

Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Frequent Contributor

Something like this?

return closest_address.street_name + " " + closest_address.house_number + ", " + closest_address.zip_code + " " + closest_address.town_name

 

Or for better readability:

var street = closest_address.street_name
var house = closest_address.house_number
var zip = closest_address.zip_code
var town = closest_address.town_name
return street + " " + house + ", " + zip + " " + town

 

I haven't figured out calling feature attributes by variables, yet:

// These work:
return $feature.Attribute
return $feature["Attribute"]

// This doesn't (in my experience):
var att = "Attribute"
return $feature[att]

// When working with features that aren't $feature (e.g. your closest_address), only this seems to work:
var f = First(Intersect(FeatureSetByName(...), $feature))
return f.Attribute

Have a great day!
Johannes
James_Norquest
New Contributor II

Johannes, Thank you so much, it works perfectly. I was overcomplicating it and didn't even need to use the concatenate function. Next I need to look at pulling the address number from a centerline file as it was done with attribute assistant. 

This helps so much!