Select to view content in your preferred language

Create spatial join on the fly

444
3
11-19-2023 10:06 PM
yockee
by
Occasional Contributor II

I have 2 layers . One is an administrative boundary (polygon) and the other is a centroid of houses (points).

I want to calculate the number of houses *automatically* as soon as the polygon has been finished and drawn up. 

how can I achieve that? I am using Arcgis Pro 3.1

QGIS has this capability https://geogear.wordpress.com/2015/01/14/spatialjoin-v1-0/

0 Kudos
3 Replies
DrewFlater
Esri Regular Contributor

Hi - you need to set up an immediately calculation attribute rule: 

https://pro.arcgis.com/en/pro-app/latest/help/data/geodatabases/overview/calculation-attribute-rules...

Which will run some Arcade code when a new feature is inserted into your geodatabase feature class. The Arcade code to run will get a Count of the Intersects because the new $feature and the house centroid points layer made into a feature set. https://community.esri.com/t5/arcgis-online-questions/arcade-expression-to-count-points-in-polygons/... 

0 Kudos
yockee
by
Occasional Contributor II

It does not work. There is error: "Invalid Expression. Error Line 1: Object Not Found. $map".

This is what I have tried:

var features = FeatureSetByName($map,'mylayer', ['*'], true);  (I also tried FeatureSetById)

$feature.atribute1 = Count(features);

 

I have 'mylayer' as one of the layer on my layer list and 'atribute1' as one of the colomn name. 

 

I am using Arcgis Pro 3.1.0 and all data are in File Geodatabase

0 Kudos
DrewFlater
Esri Regular Contributor

I have my polygon feature class and point feature class (Point_1) in the same geodatabase. And set up this immediate calculation attribute rule on inserts. So when I draw a new polygon, it automatically calculates the number of intersecting points and puts it into the count_from_att_rule field. 

DrewFlater_0-1701128377452.png

var points = FeatureSetByName($datastore, "Point_1")
var countPoints = Count(Intersects(points, $feature))
return countPoints
0 Kudos