Attribute Rules Intersect Features

04-20-2024 05:18 AM
Esri Community Manager

Hi All
I have code (Arcade) that I used inside Attributes Rules,
I have a neighborhood layer from the digitization of a paper map, and a plots layer from a field survey, meaning it is more accurate than the neighborhood layer.
When creating (Create Feature) a new plot, sometimes the plot intersects with more than one neighborhood, not only touching, but intersecting, and the intersection can be five meters, which is the difference between the paper map and the boundaries of new plots from the field survey. I would like to modify the following code:

var VILLAGE_E = FeatureSetByName ($datastore, "Blocks_Sector", ["VILLAGE_E"])
var Intersecting_feature = Intersects(VILLAGE_E, $feature)
var Out_str = null
for (var x in Intersecting_feature){
     var VILLAGE_E_VILLAGE_E = DomainName(x, 'VILLAGE_E')
     out_str = VILLAGE_E_VILLAGE_E}
return out_str

Can you modify the code for this goal?
if there is an intersection and not just a touch, the Field Value is transferred from the neighborhood with the most intersection to the plot that was created.
Pictures for clarification:

1. Create a plot of land within the neighborhood and take the correct neighborhood name



2. create a plot of land that touches more than one neighborhood, the name of the neighborhood that contains the plot has been taken, and this is correct



3. The third case is where I would like to modify the code for such cases:
A plot was created that intersects a few meters with a neighboring neighborhood, and as a result the wrong name was taken



* The name should be Abu Qash, not Surda

What is the correct code in this case?

Please help, many thanks

0 Kudos
1 Reply
Esri Frequent Contributor

I think you will need to use a function like this:

function closest_item(feat_set) {

    var closest_feature = null;
    var closest_distance = INFINITY;
    var feat_geo = Geometry($feature);
    for (var feat in feat_set) {
        var current_distance = Distance(feat_geo, Geometry(feat), 'meters');
        if (current_distance < closest_distance) {
            closest_feature = feat;
            closest_distance = current_distance;
    return closest_feature;
0 Kudos