update_bbox | R Documentation |
Function to update the coordinates of the bounding box of sf vector data objects (e.g. after cropping or subsetting).
update_bbox(sfobj)
sfobj |
Layer to be updated. |
sf
object, with corrected bounds.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.