
Expand bounding box
f.expand.bbox.RdSourced from https://rdrr.io/github/Chrisjb/basemapR/src/R/expand_bbox.R.
A function to take a bounding box (generated using sf::st_bbox()) and expand it by x meters
in the X direction and y meters in the Y direction.
Arguments
- bbox
bboxA bounding box generated bysf::st_bbox().- X
numericThe distance in meters that we want to expand the bounding box by in the X direction.- Y
numericThe distance in meters that we want to expand the bounding box by in the Y direction.- X2
numericIf specified, the meters in the Easterly direction and meters X becomes meters in the Westerly direction.- Y2
numericIf specified, the meters to the South. meters Y becomes meters to the North.- crs_out
intEPSG coordinate system to return the bounding box in. Defaults to 4326 (lat/lng).
Value
A bbox object. This can be converted into an sf object using sf::st_as_sfc().
Examples
if (FALSE) { # \dontrun{
ctry.shape <- load_clean_ctry_sp(ctry_name = "ALGERIA", st.year = 2019)
ctry.bbox <- sf::st_bbox(ctry.shape)
bbox_2 <- f.expand.bbox(ctry.bbox, 4, 4)
} # }