r - rgeos setdiff() providing unexpected result -
rgeos setdiff() problem
i have been using setdiff() rgeos many years, i've found quirk in redoing work. want overlay transparent hole on akima generated image map. find need specify 1 of hole vertices larger polygon in hole cut. here example script: library(rgeos)
changing 'maxy' 2.1 provides desired effect. why not 1.9?
maxy <- 1.9 maxy <- 2.1 x1 <- c(1, 1, 2, 2, 1) y1 <- c(1, 2, 2, 1, 1) xy1 <- cbind(x1, y1) p1 <- as(xy1, "gpc.poly") plot(p1, main="p1") x2 <- c(1.1, 1.5, 1.9, 1.1) y2 <- c(1.1, maxy, 1.1, 1.1) # note: 'maxy' here! xy2 <- cbind(x2, y2) p2 <- as(xy2, "gpc.poly") plot(p2, main="p2") plot(setdiff(p1, p2), poly.args = list(col = "grey"), main="setdiff(p1, p2)", asp=1)
if cannot fixed, there way accomplish same?
thanks ahead of time.
wiki
Comments
Post a Comment