update_bbox {SUNGEO}R Documentation

Update bounding box of sf object

Description

Function to update the coordinates of the bounding box of sf vector data objects (e.g. after cropping or subsetting).

Usage

update_bbox(sfobj)

Arguments

sfobj

Layer to be updated. sf object.

Value

sf object, with corrected bounds.

Examples

# Update bbox for subset of sf object
## Not run: 
data(clea_deu2009)
out_1 <- update_bbox(clea_deu2009[clea_deu2009$cst_n%in%c("Berlin"),])
out_1

# Bounding box of full dataset
data.table::as.data.table(clea_deu2009)[,sf::st_bbox(geometry)]

# Bounding box of subset (incorrect)
data.table::as.data.table(clea_deu2009)[cst_n%in%c("Berlin"),sf::st_bbox(geometry)]

# Corrected bounding box
data.table::as.data.table(out_1)[,sf::st_bbox(geometry)]

## End(Not run)

[Package SUNGEO version 1.3.0 Index]