rgeos setdiff()提供了意外的结果 rgeos setdiff()问题

rgeos setdiff()提供了意外的结果 rgeos setdiff()问题,r,R,多年来,我一直在使用rgeos的setdiff(),但在重做工作时发现了一个怪癖。我主要想做的是在Akima生成的图像贴图上覆盖一个透明的孔。 我发现我需要指定一个比要在其中切割孔的多边形稍大的孔顶点。 以下是示例脚本: 图书馆(rgeos) 将“maxy”更改为2.1可提供所需的效果。为什么不是1.9呢 maxy <- 1.9 maxy <- 2.1 x1 <- c(1, 1, 2, 2, 1) y1 <- c(1, 2, 2, 1, 1) xy1 <- cbin

多年来,我一直在使用rgeos的setdiff(),但在重做工作时发现了一个怪癖。我主要想做的是在Akima生成的图像贴图上覆盖一个透明的孔。 我发现我需要指定一个比要在其中切割孔的多边形稍大的孔顶点。 以下是示例脚本: 图书馆(rgeos)

将“maxy”更改为2.1可提供所需的效果。为什么不是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' is 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)
maxy