raster::erase 函数 - RGEOSBinTopoFunc 中的错误:TopologyException
raster::erase function - Error in RGEOSBinTopoFunc : TopologyException
我按照我之前的 post 解决方案使用栅格包擦除功能来剪切和溶解重叠多边形 -
对于一些多边形,我在使用擦除功能时遇到以下错误:
RGEOSBinTopoFunc (spgeom1, spgeom2, byid, id, drop_lower_td, unaryUnion_if_byid_false, 错误:
TopologyException:输入geom 1无效:在1.1197332302192855 47.203098020153668 at 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)
剧情多边形真的很乱。即使它们是有效的。问题出现在 erase
成为聚合 ("dissolves") 参数 y
("fields") 但生成无效拓扑。我需要研究如何最好地抓住它,但是,现在(也许还有一段时间),这里有一个使用 cleangeo 的解决方法,但您可能想要使用一个工具来清理字段多边形(捕捉顶点)- -- 也许使用 Rmapshaper?
library(raster)
library(rgeos)
f <- "WUERZ-I-WW _ Plot _TrialMap.shp"
fields = shapefile(f)
zone <- fields[fields$Type == "Zone", ]
plot <- fields[fields$Type == "Plot", ]
aplot <- aggregate(plot)
rgeos::gIsValid(aplot)
#[1] FALSE
#Warning message:
#In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
# Self-intersection at or near point 13.033265979999999 51.190776640000003
library(cleangeo)
cplot <- clgeo_Clean(aplot)
rgeos::gIsValid(cplot)
# TRUE
d <- erase(zone, cplot)
我按照我之前的 post 解决方案使用栅格包擦除功能来剪切和溶解重叠多边形 -
对于一些多边形,我在使用擦除功能时遇到以下错误:
RGEOSBinTopoFunc (spgeom1, spgeom2, byid, id, drop_lower_td, unaryUnion_if_byid_false, 错误: TopologyException:输入geom 1无效:在1.1197332302192855 47.203098020153668 at 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)
剧情多边形真的很乱。即使它们是有效的。问题出现在 erase
成为聚合 ("dissolves") 参数 y
("fields") 但生成无效拓扑。我需要研究如何最好地抓住它,但是,现在(也许还有一段时间),这里有一个使用 cleangeo 的解决方法,但您可能想要使用一个工具来清理字段多边形(捕捉顶点)- -- 也许使用 Rmapshaper?
library(raster)
library(rgeos)
f <- "WUERZ-I-WW _ Plot _TrialMap.shp"
fields = shapefile(f)
zone <- fields[fields$Type == "Zone", ]
plot <- fields[fields$Type == "Plot", ]
aplot <- aggregate(plot)
rgeos::gIsValid(aplot)
#[1] FALSE
#Warning message:
#In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
# Self-intersection at or near point 13.033265979999999 51.190776640000003
library(cleangeo)
cplot <- clgeo_Clean(aplot)
rgeos::gIsValid(cplot)
# TRUE
d <- erase(zone, cplot)