Learn R Programming

amt (version 0.1.7)

bbox: Get bounding box of a track.

Description

Get bounding box of a track.

Usage

bbox(x, ...)

# S3 method for track_xy bbox(x, spatial = TRUE, buffer = NULL, sf = FALSE, ...)

# S3 method for steps_xy bbox(x, spatial = TRUE, buffer = NULL, sf = FALSE, ...)

Value

If spatial = FALSE a named vector of length four with the extent of the bounding box. Otherwise a SpatialPolygon or a simple freature polygon with the bounding box.

Arguments

x

[track_xy, track_xyt]
A track created with make_track.

...

Further arguments, none implemented.

spatial

[logical(1)=TRUE]
Whether or not to return a SpatialPolygons-object or not.

buffer

[numeric(0)=NULL]{NULL, >0}
An optional buffer of the bounding box.

sf

[logical(1)=FALSE]
If TRUE a simple feature polygon is returned.

Examples

Run this code
data(deer)
bbox(deer)
bbox(deer, spatial = FALSE)
bbox(deer, buffer = 100, spatial = FALSE)

# For steps
deer %>% steps_by_burst %>% bbox(spatial = FALSE)
deer %>% steps_by_burst %>% bbox(buffer = 100, spatial = FALSE)
deer %>% steps_by_burst %>% random_steps %>% bbox(spatial = FALSE)

# There is also the option to return a `sf`-object and then work with this further.
deer %>% bbox(sf = TRUE) %>% sf::st_transform(4326)

Run the code above in your browser using DataLab