Select to view content in your preferred language

ArcGIS arcade Intersecting Polygon problems due to minor boundary overlap

969
5
10-04-2023 08:28 PM
BrennonPeterson
Emerging Contributor

I recently posted about getting help with code that returned a Y/N value based on if two polygon features intersected. The code worked great, but the two layers don't share perfectly aligned boundaries. One has a more "jagged" boundary that is visible when zoomed, causing it to flag as an intersection when it is not supposed to be. Any advice on a workaround? Would the "within" or "contains" function be more useful? Is there a way to buffer the boundary so that the slight mis-alignment doesn't produce an incorrect result?

 

Close Up boundaries.png

The larger polygons in orange are watersheds, and the smaller green polygons are impaired catchments. If there is even a single impaired catchment within a given watershed, I want to populate the field "is impaired" with "Y", or "N".Large watersheds and small catchments.png

 

 

 

 

 

 

 

 

My current code:

var ImpCatchments = Intersects(Featuresetbyname($datastore, "attains_au_catchments_Impaired"), $feature)
var cnt = count(ImpCatchments)
IIF(cnt > 0, "Y", "N");

 

 

Any help would be very much appreciated!

0 Kudos
5 Replies
JohannesLindner
MVP Frequent Contributor

You can use a small negative buffer:

var ImpCatchments = Featuresetbyname($datastore, "attains_au_catchments_Impaired")
var IntImpCat = Intersects(Buffer($feature, -10, "meters"), ImpCatchments)
var cnt = count(IntImpCat)
IIF(cnt > 0, "Y", "N");

Have a great day!
Johannes
BrennonPeterson
Emerging Contributor

This is what I was looking for! Though, I received an error, and it doesn't seem to be doing what is intended. The initial error I got was that "search geometry cannot be null". I assumed that maybe the buffer created null values, so I added and if-else statement to negate the error. Even with the buffer, I am still getting "Y" values for intersection where I shouldn't. I even expanded the buffer up to -40 meters with no success.

Code I am using:

var ImpCatchments = Featuresetbyname($datastore, "attains_au_catchments_Impaired")
var IntImpCat = Intersects(Buffer($feature, -20,"meters"),ImpCatchments)
If(Geometry(Buffer($feature, -20,"meters"))==null)
{
return "Geometry Null";
}
else
{
var cnt = count(IntImpCat)
IIF(cnt > 0, "Y", "N");
}

0 Kudos
JohannesLindner
MVP Frequent Contributor

Null geometries are created when you try to buffer too much. You probably have small polygons in your fc. In these cases, the buffer of one side would end up on the outside of the polygon on the other side, resulting in a null geometry. This is difficult to explain, so here is a quick sketch:

JohannesLindner_0-1696532755735.png

On the left, a polygon (black) and a negative buffer (red) with appropriate buffer distance (blue).

On the right, the buffer distance is too big for the polygon, so the buffer's sides would end up outside of the polygon, creating a nonsensical geometry (not saying that the buffer algorithm actually works this way, just as a concept).

 

tl;dr: use an appropriately small buffer size or exclude polygons with small area from the calculation.

 

To use your check, you have to put it before the actual error:

var ImpCatchments = Featuresetbyname($datastore, "attains_au_catchments_Impaired")

var NegBuffer = Buffer($feature, -20, "meters")
if(NegBuffer == null) { return "Polygon too small" }

var IntImpCat = Intersects(NegBuffer,ImpCatchments)
var cnt = count(IntImpCat)
return IIF(cnt > 0, "Y", "N")

Have a great day!
Johannes
BrennonPeterson
Emerging Contributor

Thank you for the explanation! Though, I get all null values when I run that code. Even for my largest polygons that shouldn't pose a problem...

 

0 Kudos
JohannesLindner
MVP Frequent Contributor

Hmm... Difficult to  say what's wrong without the actual data. Would it be possible to send me an extract of your data? Either here or in a pm.


Have a great day!
Johannes
0 Kudos