Learn R Programming

marmap (version 0.9.4)

create.buffer: Create a buffer of specified radius around one or several points

Description

Create a circular buffer of user-defined radius around one or several points defined by their longitudes and latitudes.

Usage

create.buffer(mat, loc, radius, km = FALSE)

Arguments

mat
an object of class bathy
loc
a 2-column data.frame of longitudes and latitudes for points around which the buffer is to be created.
radius
numeric. Radius of the buffer in the same unit as the bathy object (i.e. usually decimal degrees) when km=FALSE (default) or in kilometers when radius=TRUE.
km
logical. If TRUE, the radius should be provided in kilometers. When FALSE (default) the radius is in the same unit as the bathy object (i.e. usually decimal degrees).

Value

  • An object of class bathy of the same size as mat containing only NAs outside of the buffer and values of depth/altitude (taken from mat) within the buffer.

Details

This function takes advantage of the buffer function from package adehabitatMA and several functions from packages sp to define the buffer around the points provided by the user.

See Also

outline.buffer, combine.buffers, plot.bathy

Examples

Run this code
# load and plot a bathymetry
data(florida)
plot(florida, lwd = 0.2)
plot(florida, n = 1, lwd = 0.7, add = TRUE)

# add points around which a buffer will be computed
loc <- data.frame(c(-80,-82), c(26,24))
points(loc, pch = 19, col = "red")

# compute buffer
buf <- create.buffer(florida, loc, radius=1.5)

# highlight isobath with the buffer and add outline
plot(buf, add = TRUE, n = 10, col = 2, lwd=.4)
plot(outline.buffer(buf), add = TRUE, lwd = 0.7, col = 2)

Run the code above in your browser using DataLab