buffer: Create a buffer around vector geometries or raster patches

bufferR Documentation

Create a buffer around vector geometries or raster patches

Description

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.

Usage

## S4 method for signature 'SpatRaster'
buffer(x, width, background=0, filename="", ...)

## S4 method for signature 'SpatVector'
buffer(x, width, quadsegs=10)

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

...

additional arguments for writing files as in writeRaster

background

numeric. value to assign to cells outside the buffer. If this value is zero or FALSE, a boolean SpatRaster is returned

quadsegs

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

Value

Same as x (SpatRaster or SpatVector). For SpatRaster: cells inside the buffers have the value 1.

See Also

distance, elongate

Examples

r <- rast(ncols=36, nrows=18)
r[500] <- 1
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)

terra documentation built on Nov. 18, 2022, 5:11 p.m.