Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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 signature 'SpatRaster'
buffer(x, width, 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

quadsegs

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

Value

SpatRaster

See Also

Examples

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)), crs="+proj=merc")
b <- buffer(v, 20)
plot(b)
points(v)

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

terra

Spatial Data Analysis

v1.2-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Roger Bivand [ctb] (<https://orcid.org/0000-0003-2392-6140>), Karl Forner [ctb], Jeroen Ooms [ctb] (<https://orcid.org/0000-0002-4035-0289>), Edzer Pebesma [ctb] (<https://orcid.org/0000-0001-8049-7069>)
Initial release
2021-05-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.