arcpy (st_overlaps) 中同一数据集中所有 objects 的重叠

Overlaps of all objects within the same dataset in arcpy (st_overlaps)

Rsf 在标题 "Geometric binary predicates" 下有一组惊人的功能,在 here.

中有详细描述

如 link 中所述,如果只有一个 sf-[=49=,则函数递归应用于同一数据集 中的所有几何 ] 提供(参见下面的示例)

If y is missing, st_predicate(x, x) is effectively called, and a square matrix is returned with diagonal elements st_predicate(x[i], x[i]).

但是现在,我正在构建一些工具,这些工具与 ArcGIS arcpy 绑定。什么是快速获取同一数据集中所有特征的方阵以指示各个特征是否重叠的方法?

arcpy.SpatialJoin_analysis()只比较两个数据集,arcpy.GenerateNearTable_analysis()arcpy.Near_analysis()只计算特征之间的距离。

这就是 st_overlaps()R 中的工作方式:

library(sf)
#> Warning: Paket 'sf' wurde unter R Version 3.5.2 erstellt
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3

b0 = st_polygon(list(rbind(c(-1,-1), c(1,-1), c(1,1), c(-1,1), c(-1,-1))))
a0 = b0 * 0.8
a1 = a0 * 0.5 + c(2, 0.7)
a2 = a0 + 1
a3 = b0 * 0.5 + c(2, -0.5)
y = st_sfc(a0,a1,a2,a3)

plot(y)

st_overlaps(y,sparse = F)
#>       [,1]  [,2]  [,3]  [,4]
#> [1,] FALSE FALSE  TRUE FALSE
#> [2,] FALSE FALSE  TRUE FALSE
#> [3,]  TRUE  TRUE FALSE FALSE
#> [4,] FALSE FALSE FALSE FALSE

reprex package (v0.2.1)

于 2019-04-16 创建

实现此目的的一种方法:

  1. 使用 'intersect' 工具将所有多边形在它们重叠的地方分开。
  2. 使用 'find duplicates' 工具生成具有相同形状的多边形列表。
  3. 使用对象 ID 将这些过程的结果加入原始 table。连接到位后,您会在 'Feat_Seq' 字段中看到用相同值标记的重叠多边形。

样本python:

arcpy.analysis.Intersect("test.shp", "test_Intersect", "ONLY_FID", None, "INPUT")
arcpy.management.FindIdentical("test_Intersect", r"test_Intersect_FindIdentical", "Shape", None, 0, "ONLY_DUPLICATES")
arcpy.management.AddJoin("test", "FID", "test_Intersect", "FID_test", "KEEP_ALL")
arcpy.management.AddJoin("test", "test_Intersect.OBJECTID", "test_Intersect_FindIdentical", "IN_FID", "KEEP_ALL")