[R-sig-Geo] gBuffer solution to invalid objects problem fails
Kenny Bell
kmb56 at berkeley.edu
Wed May 18 19:08:21 CEST 2016
Hi all,
I have been getting the below error a few times. I have seen in several
places that a zero-width gBuffer call will fix the topology problem.
However, in this case, I find that the call to gBuffer generates a 4 point
horizontal line, not solving the problem. Is there another solution? Thanks
for any help!
My code:
library(sp)
library(rgeos)
load("r-sig-geo.RData")
gIntersection(grid_poly, new_poly,
byid = c(TRUE, FALSE),
id = as.character(grid_poly at data[,1]),
# if there are coinciding lines, gIntersection
# returns a cross.
drop_lower_td = TRUE,
checkValidity = TRUE)
# new_poly is invalid
# Error in rgeos::gIntersection(grid_poly, new_poly, byid = c(TRUE, FALSE),
:
# Invalid objects found
# In addition: Warning message:
# In RGEOSUnaryPredFunc(spgeom, byid,
"rgeos_isvalid") :
# Self-intersection at or near point
172.23206269997971 -42.13157792003453
# Try using gBuffer as suggested here:
#
http://gis.stackexchange.com/questions/163445/r-solution-for-topologyexception-input-geom-1-is-invalid-self-intersection-er
new_poly1 <- gBuffer(new_poly, width = 0)
plot(new_poly1)
# Generates a line (i.e. kills the polygon)
r-sig-geo.RData
<https://www.dropbox.com/s/9ivpcmboodpu6zd/r-sig-geo.RData?dl=0>
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list