Learn R Programming

ptools (version 2.0.0)

buff_sp: Creates buffer of sp polygon object

Description

Creates buffer of sp polygon object. Intended to replace raster::buffer, which relies on rgeos

Usage

buff_sp(area, radius, dissolve = TRUE)

Value

A SpatialPolygonDataFrame object (when dissolve=FALSE), or a SpatialPolygon object (when dissolve=TRUE)

Arguments

area

SpatialPolygon or SpatialPolygonDataFrame that defines the area

radius

scaler for the size of the buffer (in whatever units the polygon is projected in)

dissolve

boolean (default TRUE), to dissolve into single object, or leave as multiple objects

Details

Under the hood, this converts sp objects into sf objects and uses st_buffer. When dissolve=TRUE, it uses st_union(area) and then buffers.

Examples

Run this code
# \donttest{
library(sp) #for sp plot methods
# large grid cells
data(nyc_bor)
res <- buff_sp(nyc_bor,7000)
plot(nyc_bor)
plot(res,border='BLUE',add=TRUE)

# When dissolve=FALSE, still returns individual units
# that can overlap
res2 <- buff_sp(nyc_bor,7000,dissolve=FALSE)
plot(res2)
# }

Run the code above in your browser using DataLab