Select to view content in your preferred language

Arcade expressions to update the number in another layer

159
1
4 weeks ago
Labels (1)
witcherrie
New Contributor

Hello,

I am pretty new at Arcade expressions and I struggle deeply with making specific expression.

I have the point layer, let's call it ,,Points".

I have the polygon layer, let's call it ,,Polygons". 

Some points are in the polygons from "Polygons" and if they are falling into the specific polygon they get from this specific polygon id called No. The attribute No. exist in ,,Polygons" and in ,,Points". 

In the polygon layer I have the attribute ,,Number of points" and I already made the attribute rule that counts the number of points in this layer. ,,Number of points" is also updating while I move the points, but it's not working when I delete the point. 

What is wrong with this code?

var fs = FeatureSetByName($datastore, "Polygons")
var updates=[]
var i =0
for(var pol in fs){
if(pol.id ==$feature.id){
updates[i++] = {'globalid': pol.globalid,
                'attributes': {'No': -1}
               }
}

}
return {
   'result': $feature.field_in_point_layer, 
   'edit': [{
        'className': 'Polygons',
        'updates': updates           
    }]
}

 

Tags (2)
0 Kudos
1 Reply
witcherrie
New Contributor

I am sorry, the attribute that is the same for both point and polygon layer is ,,id", the attribute with the number of points is called ,,No".

0 Kudos