Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer() of multipoint surrounds a single point #1607

Closed
AMBarbosa opened this issue Sep 23, 2024 · 2 comments
Closed

buffer() of multipoint surrounds a single point #1607

AMBarbosa opened this issue Sep 23, 2024 · 2 comments

Comments

@AMBarbosa
Copy link
Contributor

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!

@rhijmans
Copy link
Member

rhijmans commented Oct 3, 2024

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)

@rhijmans
Copy link
Member

rhijmans commented Oct 3, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants