Learn R Programming

spatialEco (version 2.0-2)

squareBuffer: Square buffer

Description

Creates a square buffer of a feature class

Usage

squareBuffer(x, a, ...)

Value

A single feature sf class polygon object

Arguments

x

An sf object

a

Numeric single or vector indicating buffer distance(s)

...

Additional arguments passed to st_buffer

Author

Jeffrey S. Evans <jeffrey_evans@tnc.org>

Details

Function creates a square buffer of feature class.

Examples

Run this code
library(sf)
xy <- st_as_sf(data.frame(x = c(1,3,6,7),
               y = c(3,2,7,8), z = c(38,23,12,12),
               area = c(32,23,45,67)),
			      coords = c("x", "y"), 
			      agr = "constant") 

# With fixed buffer
sb <- squareBuffer(xy, 32)
  plot(st_geometry(sb))
    plot(st_geometry(xy), pch=20, add=TRUE)
  
# With variable buffer
sb.var <- squareBuffer(xy, xy$area)
  plot(st_geometry(sb.var))
    plot(st_geometry(xy), pch=20, add=TRUE)
  

Run the code above in your browser using DataLab