Point to Point Intersection Arcade

2062
6
Jump to solution
04-17-2019 04:01 PM
NaomiBegg2
Occasional Contributor III

I have tried to create an expression that captures everything under a point to show in a popup using the below.

var intersectLayer =Intersects(FeatureSetByName($map,"NZ Parcels"), $feature)
for (var f in intersectLayer){
return f.parcel_intent
}

I do not get an error but nothing shows.

I've tested this on a few different scenarios and have found that it works for polygon to polygon and for polygon to point intersects but does not seem to work when it starts with a point. 

How do I intersect starting with a point?

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

I would probably apply a buffer in the Arcade expression first to ensure that the intersects will return results. So you will not do the Intersects with the original point $feature, but with the buffer. 

View solution in original post

0 Kudos
6 Replies
XanderBakker
Esri Esteemed Contributor

I would probably apply a buffer in the Arcade expression first to ensure that the intersects will return results. So you will not do the Intersects with the original point $feature, but with the buffer. 

0 Kudos
XanderBakker
Esri Esteemed Contributor

To provide you with a little more information on the general idea, have a look at the sample below:

var intersectLayer = Intersects(FeatureSetByName($map,"NZ Parcels"), Buffer($feature, 10, "meters"))
var cnt = Count(intersectLayer);
var result = "There are " + cnt + " intersections:";
for (var f in intersectLayer) {
    result += TextFormatting.NewLine + f.parcel_intent;
}

return result;

Notice that I don't use the point ($feature), but the result of a buffer of 10 meters with the Intersects function.

NaomiBegg2
Occasional Contributor III

Hi Xander Bakker‌ I'm trying to do a similar script of finding out if two point layer buffers overlap, however I'm coming across Execution Error: Illegal Argument

var IntersectsPole = intersects(BUFFER($feature, 5, "meters"),BUFFER(FeatureSetByName($map,"Taupo_Poles_view"),1,"meters"));
for (var f in IntersectsPole) {
var a = f. pole_id;
}

return a

What very simple thing have I forgotten?

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Naomi Begg ,

You provide a featureset to the second buffer function, but a buffer can only be calculated on a single feature. Also you loop through the found feature and return the id of the last one. Is that what you are after?

Could you try this:

// you can search for poles in a distance of 6 m (5+1)
var IntersectsPole = Intersects(Buffer($feature, 6, "meters"), FeatureSetByName($map,"Taupo_Poles_view"));

// for the first pole id do this:
var poleid = First(IntersectsPole).pole_id;
return poleid;

// for a list of pole ids:
var poleids = [];
for (var f in IntersectsPole) {
    poleids[Count(poleids)]=f.pole_id;
}
var poleid = Concatenate(poleids, ", ");
return poleid;
NaomiBegg2
Occasional Contributor III

Thanks Xander.

I'm not sure why my brain decided to try and overkill it with two buffers.  I knew that there is likely some location error on both layers so maybe that was why.

This was to find the closest power pole to a tree, however there will not be a cluster of poles near a tree so finding the first one within 5 meters works. 

XanderBakker
Esri Esteemed Contributor

Hi Naomi Begg , if my post answered your question, could you mark it as the correct answer? This way it will be easier for other users to find the answer. Thanks!

0 Kudos