i have two layers one is High Tide Line and another one is Land Parcel. Land parcel is a polygon feature class and High tide line is a line feature class. I want to add the straight line distance at nearest vertex of the High Tide line layer to the centroid of the land parcel layer feature i am creating. I had written a Arcade Script and its not working for me. Can anyone help?. Thanks in Advance.
var landParcelLayer = FeatureSetByName($map, "Land Parcel"); // Replace with the actual name of your Land Parcel layer
var highTideLayer = FeatureSetByName($map, "High Tide Line HTL"); // Replace with the actual name of your High Tide Line layer
var attributeName = 'Dist_HTL'; // Replace with the desired attribute name
var editingFeature = $feature;
var landParcelGeometry = Geometry(editingFeature);
var closestDistance = 999999999; // Set a large initial value
for (var vertex in highTideLayer) {
var vertexGeometry = Geometry(vertex);
var distance = Distance(vertexGeometry, Centroid(landParcelGeometry));
if (distance < closestDistance) {
closestDistance = distance;
}
}
if (closestDistance < 999999999) {
editingFeature[attributeName] = closestDistance;
return editingFeature;
} else {
return 'No Nearby High Tide Line Features';
}