Attribute Rules Intersect Features

225
1
03-21-2024 01:49 PM
Labels (1)
HusamJubeh
New Contributor III

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

HusamJubeh_0-1711053931129.png

 

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

HusamJubeh_1-1711053930865.png

 

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

HusamJubeh_2-1711053931034.png

 

* The name should be Abu Qash, not Surda

What is the correct code in this case?

Please help, many thanks

Tags (2)
0 Kudos
1 Reply
ShareUser
Esri Community Manager

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