Select to view content in your preferred language

Closest feature to End of line

385
1
01-29-2024 03:23 PM
Labels (1)
ksitom
by
New Contributor

I have the following expression, but " var distSub = Distance(f, pEnd);" returns an error "Geometry type expected".

Not sure what I am missing here.

I would appreciate the community's help.

 

var searchDist = 10;
var pEnd = Geometry($feature).paths[-1][-1];
var fsSub = FeatureSetbyName ($datastore,'Sub_11kV', ['OBJECTID','Name','SubAssetNo'], false);
var fBuf = Buffer(pEnd, searchDist, 'meters')
var fSub = Intersects(fsSub, fBuf);
var cnt = Count(fSub);
var nearSub;
var minDist = searchDist;
for (var f in fSub){
  var distSub = Distance(f, pEnd);
  if (distSub < minDist) {
    nearSub = f.SubAssetNo;
    minDist = distSub;
  }
}
return IIf(nearSub==null,'',nearSub);

0 Kudos
1 Reply
DavidPike
MVP Frequent Contributor

I Think if you looked at the type for fSub it would be Boolean rather than a Geometry.  Try Intersection() rather than Intersects(). https://developers.arcgis.com/arcade/function-reference/geometry_functions/#intersection

 

0 Kudos