Skip to contents

Takes an area as an sf object or a bounding box and returns a bounding box that matches the provided aspect ratio and contains the area or bounding box provided.

Usage

st_bbox_ext(
  x = NULL,
  dist = NULL,
  diag_ratio = NULL,
  asp = NULL,
  unit = NULL,
  crs = NULL,
  class = "bbox",
  null.ok = TRUE
)

st_bbox_asp(x = NULL, asp = NULL, class = "bbox")

Arguments

x

An object sf, bbox, sfc, raster, or sp object or a data frame that can be converted to an sf object or a list of sf, bbox, or sfc objects. st_bbox_asp also supports vectors in the same format as a bbox object.

dist

buffer distance in units. Optional.

diag_ratio

ratio of diagonal distance of area's bounding box used as buffer distance. e.g. if the diagonal distance is 3000 meters and the "diag_ratio = 0.1" a 300 meter will be used. Ignored when dist is provided.

asp

Aspect ratio of width to height as a numeric value (e.g. 0.33) or character (e.g. "1:3"). If numeric, get_asp() returns the same value without modification.

unit

Units for buffer. Supported options include "meter", "foot", "kilometer", and "mile", "nautical mile" Common abbreviations (e.g. "km" instead of "kilometer") are also supported. Distance in units is converted to units matching GDAL units for x; defaults to "meter"

crs

Coordinate reference system of bounding box to return

class

Class of object to return (sf or bbox); defaults to "bbox".

null.ok

If TRUE and x is NULL, return NULL.

Value

Class bbox object

Details

Common aspect ratios include "1:1" (1), "4:6" (0.666), "8.5:11", "16:9" (1.777). The asp parameter supports both numeric values and character strings with ratios matching the format of "width:height".