buffer {terra} | R Documentation |
Calculate a buffer around all cells that are not NA
in a SpatRaster, or around the geometries of a SpatVector)
Note that the distance unit of the buffer width
parameter is meters if the CRS is (+proj=longlat
), and in map units (typically also meters) if not.
## S4 method for signature 'SpatRaster'
buffer(x, width, filename="", ...)
## S4 method for signature 'SpatVector'
buffer(x, width, quadsegs=10)
x |
SpatRaster or SpatVector |
width |
numeric. Unit is meter if |
filename |
character. Output filename |
... |
additional arguments for writing files as in |
quadsegs |
positive integer. Number of line segments to use to draw a quart circle |
SpatRaster
r <- rast(ncols=36, nrows=18)
v <- rep(NA, ncell(r))
v[500] <- 1
values(r) <- v
b <- buffer(r, width=5000000)
plot(b)
v <- vect(rbind(c(10,10), c(0,60)), crs="+proj=merc")
b <- buffer(v, 20)
plot(b)
points(v)
crs(v) <- "+proj=longlat"
b <- buffer(v, 1500000)
plot(b)
points(v)