Skip to contents

Takes an `sf` object or a `terra::SpatRaster` as input and returns a new `sf` object representing the bounding box (minimum bounding rectangle) of the input layer.

Usage

generate_bbox(layer)

Arguments

layer

An `sf` object or a `terra::SpatRaster` object.

Value

An `sf` object representing the bounding box of the input layer.

See also

Other clip functions: clip_layer(), clip_multipoligon(), clip_raster()

Examples

# Example with a vector layer
source_gpkg <- system.file("extdata/sigugr.gpkg", package = "sigugr")
lanjaron <- sf::st_read(source_gpkg, layer = "lanjaron", quiet = TRUE)
bbox_vector <- generate_bbox(lanjaron)

# Example with a raster layer
raster_file <- system.file("extdata/sat.tif", package = "sigugr")
raster <- terra::rast(raster_file)
bbox_raster <- generate_bbox(raster)