Skip to content
Prev 24407 / 29559 Next

gBuffer solution to invalid objects problem fails

Great, this works:

new_poly <- sp::spTransform(new_poly, "+proj=tmerc +lat_0=0 +lon_0=173
+k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +units=m +no_defs")
grid_poly <- sp::spTransform(grid_poly, "+proj=tmerc +lat_0=0 +lon_0=173
+k=0.9996 +x_0=1600000 +y_0=10000000 +ellps=GRS80 +units=m +no_defs")
new_poly1 <- gBuffer(new_poly, width = 0)
plot(new_poly1)
# Works
gIntersection(grid_poly, new_poly1,
              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)

Thanks so much Roger!
On Thu, May 19, 2016 at 12:02 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote: