簡體   English   中英

使用 sf 在 R 中查找具有非重疊區域的多邊形

[英]Find polygons with regions of non overlap in R using sf

我在 shapefile 中有兩組多邊形,使用 R 的 sf 包導入。 我會稱他們為 A 和 B。

我想獲得所有多邊形在B,其中有或者a)在甲任何多邊形,或b)與A.多邊形一些非重疊0%重疊

例如,對於 B 中的給定多邊形b ,我希望b 100% 包含在 A 中的兩個(或三個或四個...)多邊形中的區域。

但是,假設b 50% 包含在 A 中的兩個(或三個或四個...)多邊形中,但其中 50% 不包含在 A 中的任何其他多邊形中。在這種情況下,我想選擇b 或者如果b 的100% 在 A 中的所有多邊形之外,我想選擇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() 函數完全覆蓋這個用例。 這就是我試圖做的。 我會盡快關閉它,因為我認為這給了我需要的答案。 感謝大家的幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM