如何修复“与”其他多边形“相交”的错误子集多边形?

问题描述 投票:0回答:0

我有 459 个多边形,每个多边形代表一个物种的地理分布:

library(sf)
polA <- st_read("species.gpkg")

Simple feature collection with 459 features and 3 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -180 ymin: -34.83514 xmax: 180 ymax: 75.36986
Geodetic CRS:  WGS 84

我还有另一个地理多边形:

polB <- st_read("Geographic.shp")

Simple feature collection with 38 features and 1 field
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -186.5396 ymin: 7.206111 xmax: -12.15764 ymax: 83.6236
Geodetic CRS:  WGS 84

我只想保留接触“polB”的“polA”中的多边形。

我尝试使用 spatialEco 包的简单方法:

filtered <- spatial.select(polB, polA, predicate = "intersect")

或者使用 sf 包中的 sf_filter():

filtered <- st_filter(polB, polA, .pred = st_intersects)

然而,在这两种情况下我都得到了同样的错误:

Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'sort': error in evaluating the argument 'x' in selecting a method for function 'unique': Loop 478 is not valid: Edge 15647 has duplicate vertex with edge 15652

我试图探索为什么会出现此错误,但找不到解决方案或其他方法来获得所需的结果。你有什么想法吗?

谢谢你的好处

subset multipolygons
© www.soinside.com 2019 - 2024. All rights reserved.