Greetings all,
In my database I have a point file of event locations, and another point file showing the position of people during each event. I want to perform a field calculation to record how many people were within a 5m radius of each event.
I know for one-to-many relationships, you must relate the tables, but I cannot use the field calculator like I would if I could join the table. Is there any way to do this in ArcGIS Pro? I don't mind using Python if need be.
Solved! Go to Solution.
Create a new integer field in your event fc. Do not join the tables. Calculate the new field, switch to Arcade, edit and use this code.
var people_fc = FeatureSetByName($datastore, "PeopleFeatureclass", ["ObjectID"], true)
return Count(Intersects(Buffer($feature, 5), people_fc))
Create a new integer field in your event fc. Do not join the tables. Calculate the new field, switch to Arcade, edit and use this code.
var people_fc = FeatureSetByName($datastore, "PeopleFeatureclass", ["ObjectID"], true)
return Count(Intersects(Buffer($feature, 5), people_fc))
Just ran your code with my variables, and it worked perfectly! Thank you very much, Johannes.
Hello,
I am having a similar issue and am wondering how this code can be modified with my situation. I have a polygon feature class in a FGDB that is related to a table in the same FDGB. In the table, there are multiple rows that need to match up with one polygon in the feature class. I would like to field calculate field attributes from the table to the polygon layer. Can this be done with a variation of this code? Thank you in advance.
If you have built a relationship class, you can get the related table entries like this:
var related = FeatureSetByRelationshipName($feature, "NameOfTheRelationshipClass")
If not, you have to load and filter the table like this:
var table = FeatureSetByName($datastore, "NameOfTheTable")
var id = $feature.PrimaryKey
var related = Filter(table, "ForeignKey = @ID")
And then it depends on what you want to extract from the related table entries. Some examples:
// Return the count
return Count(related)
// return max/min/mean/sum of a field
return Max(related, "FieldName")