rspatial/terra

buffer() of multipoint surrounds a single point

Closed this issue · 2 comments

I expected a buffer() around a multipoint to surround the entire object, but it seems to refer to just one (and not even a central) point:

lux <- vect(system.file("ex/lux.shp", package="terra"))
multipoint <- aggregate(centroids(lux))
buf <- buffer(multipoint, width = 10000)
plot(multipoint, ext = ext(multipoint) + ext(buf))
plot(buf, add = TRUE)

Is this expected? Cheers!

Not expected. It is a bug for lonlat points as it seems to work OK for planar points

crs(multipoint) = "local"
buf <- buffer(multipoint, width = .1)
plot(buf); points(multipoint)

This seems to work now:

library(terra)
lux <- vect(system.file("ex/lux.shp", package="terra"))
p <- centroids(lux)
d <- 9000
bp <- buffer(p, width = d)
m <- aggregate(p)
ba <- buffer(m, width = d)
plot(bp, border="light gray"); lines(ba, col="red", lwd=2); points(m)

buffer