Skip to contents

Sourced 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.

Usage

f.expand.bbox(bbox, X, Y, X2 = X, Y2 = Y, crs_out = 4326)

Arguments

bbox

bbox A bounding box generated by sf::st_bbox().

X

numeric The distance in meters that we want to expand the bounding box by in the X direction.

Y

numeric The distance in meters that we want to expand the bounding box by in the Y direction.

X2

numeric If specified, the meters in the Easterly direction and meters X becomes meters in the Westerly direction.

Y2

numeric If specified, the meters to the South. meters Y becomes meters to the North.

crs_out

int EPSG 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)
} # }