使用 sf 在 R 中查找具有非重叠区域的多边形

Find polygons with regions of non overlap in R using sf

我在 shapefile 中有两组多边形,使用 R 的 sf 包导入。我称他们为 A 和 B。

我想获取 B 中的所有多边形,其中 a) 与 A 中的任何多边形重叠 0% 或 b) 一些 与 A 中的多边形不重叠.

例如,对于 B 中的给定多边形 b,我 想要 b 100% 包含在 A 中的两个(或三个或四个...)多边形中。

但是,假设 b 50% 包含在 A 中的两个(或三个或四个...)多边形中,但其中的 50% 不包含在任何其他多边形中A 中的多边形。在那种情况下,我想 select b。或者如果 b 的 100% 在 A 中的所有多边形之外,我想 select b.

有没有可能使用 st_intersects 来做到这一点?如果图表或其他东西有助于澄清,请告诉我。

======

更明确地说:

我有类似的东西

## A is an sf object with many polygons, and so is B
## they both are part of the same geospatial area, 
## with some non-overlapping regions and many overlapping.
## I want all polygons in B that partially but not fully
## are covered by A. That is, I'm searching for regions of 
## the area not entirely covered by A, but if A covers it,
## I don't need B.

## So consider a loop approach

for (b in 1:nrow(B)) {
   
   if( !st_intersects(B[b,], A) {
       ....
   }
}

这就是我卡住的地方...我不太确定我应该将多边形与 A 还是与 st_combine(A) 进行比较。而且我不确定如何设置 st_intersects 以获得非重叠区域,或使用 st_intersection。我对 sf 有点陌生,我以前都用过,但只是为了测试 一些 重叠,从来没有测试过这样的情况。

我才恍然大悟,我认为可以使用 st_crop() 函数完全涵盖这个用例。这就是我想要做的。我会尽快关闭它,因为我认为这给了我需要的答案。感谢大家的帮助。