terra (version 1.0-10)

buffer: Create a buffer around vector objects or raster patches

Description

Calculate a buffer around all cells that are not NA in a SpatRaster, or around the geometries of a SpatVector (currently only implemented for points)

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.

Usage

# S4 method for SpatRaster
buffer(x, width, filename="", overwrite=FALSE, wopt=list(), ...)

# S4 method for SpatVector buffer(x, width, quadsegs=10, capstyle="round", ...)

Arguments

x

SpatRaster or SpatVector

width

numeric. Unit is meter if x has a longitude/latitude CRS, or mapunits in other cases. Should be > 0 for SpatRaster

filename

character. Output filename. Optional

overwrite

logical. If TRUE, filename is overwritten

wopt

list. Options for writing files as in writeRaster

...

additional arguments. None implemented

quadsegs

postive integer. Number of line segments to use to draw a quart circle

capstyle

character. Style of cap to use at the ends of the geometry. Allowed values: "round", "flat", "square" (ignored for now)

Value

SpatRaster

See Also

distance

Examples

Run this code
# NOT RUN {
r <- rast(ncol=36,nrow=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)))
b <- buffer(v, 20)
plot(b)
points(v)

crs(v) <- "+proj=longlat +datum=WGS84"
b <- buffer(v, 1500000)
plot(b)
points(v)
# }

Run the code above in your browser using DataLab