raster :: erase函数-RGEOSBinTopoFunc中的错误:TopologyException

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

我按照先前的解决方案使用栅格数据包擦除功能来剪切和溶解重叠的多边形-Dissolve Overlapping Polygons using difference and union in R

对于某些多边形,擦除功能出现以下错误:

RGEOSBinTopoFunc(spgeom1,spgeom2,byid,id,drop_lower_td,unaryUnion_if_byid_false,TopologyException:输入几何1无效:位于1.1197332302192855 47.203098020153668的点或附近的自相交于1.1197332302192855 47.203098020153668

library(raster)
library(rgeos)
library(sp)

fields <- gBuffer(fields, byid=TRUE, width=0) # Expands the given geometry to include 
the area within the specified width 

zone <- fields[fields$Type == "Zone", ]
plot <- fields[fields$Type == "Plot", ]

d <- erase(zone, plot) #issue here
spplot(d, "Rx")

# I tried using rgeos::gBuffer to avoid RGEOSBinTopology Exception but it did not worked out. Any guidance in this area would be really helpful.

zone <- gBuffer(zone, byid=TRUE, width=0)
plot <- gBuffer(plot, byid=TRUE, width=0)
r raster r-raster rgeo-shapefile
1个回答
0
投票

图的多边形非常混乱。即使它们是有效的。问题出现在erase变成其聚合(“溶解”)参数y(“字段”),但生成无效拓扑的情况。我需要研究如何最好地捕捉这一点,但是现在(也许有一段时间),这是使用cleangeo的一种变通方法,但是您可能想要使用一种工具来清理字段多边形(捕捉顶点)- -也许使用Rmapshaper?

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