Simple bounding box functions that you can use to:
Usage
sf_bbox_asp(bbox, orientation = FALSE)
sf_bbox_point(bbox, point = NULL)
sf_bbox_dist(bbox, from, to, units = NULL, drop = TRUE)
sf_bbox_xdist(bbox, units = NULL, drop = TRUE)
sf_bbox_ydist(bbox, units = NULL, drop = TRUE)
sf_bbox_diagdist(bbox, units = NULL, drop = TRUE)
sf_bbox_transform(bbox, crs = NULL)
sf_bbox_to_sf(bbox, sf_col = "geometry")
sf_bbox_to_sfc(bbox)
sf_bbox_to_wkt(bbox)
sf_bbox_to_lonlat_query(bbox, coords = c("longitude", "latitude"), crs = 4326)
sf_bbox_shift(
bbox,
x_nudge = 0,
y_nudge = 0,
side = c("all", "top", "bottom", "left", "right"),
dir = NULL
)
sf_bbox_contract(bbox, x_nudge = 0, y_nudge = 0)
sf_bbox_expand(bbox, x_nudge = 0, y_nudge = 0)
Arguments
- bbox
A bbox object.
- orientation
If
TRUE
, sf_bbox_asp returns a suggested orientation based on aspect ratio (< 0.9 "portrait"; > 1.1 "landscape"; else "square"); defaults toFALSE
.- point
Length 2 character vector representing a coordinate pair at a corner, midpoint, or center of the bounding box ("xmin", "ymin", "xmax", "ymax", "xmid", "ymid")
- from, to
xy pairs (e.g. c("xmax", "ymax) defining points to measure distance from and to.
- units
The units to return for sf_bbox_dist. Defaults to NULL.
- drop
If
FALSE
, distance functions return with units. IfFALSE
(default), distance functions return numeric values.- crs
coordinate reference system to use for query; default 4326
- sf_col
name to use for geometry column after converting to simple feature object; defaults to "geometry".
- coords
query column names with coordinates. e,g, c("X", "Y") or c("lat", "lon")
- x_nudge, y_nudge
Length 1 or 2 numeric vector; unitless.
- side
one or more sides to shift: "top", "bottom", "left", "right", or "all"
- dir
If "in", contract the
bbox
by x_nudge and y_nudge. If "out", expand the bbox by x_nudge and y_nudge. If dir is notNULL
; absolute values are used for x_nudge and y_nudge. Defaults toNULL
.
Details
Measure distances (sf_bbox_dist, sf_bbox_xdist, sf_bbox_ydist, and sf_bbox_diagdist)
Get an aspect ratio or orientation (sf_bbox_asp) (counts asp between 0.9 and 1.1 as "square")
Return a point from any of the corners, center, or midpoints (sf_bbox_point)
Transform the coordinate reference system (sf_bbox_transform)
Convert a bounding box to a SQL style query (sf_bbox_to_lonlat_query), well known text (sf_bbox_to_wkt), or a simple feature object (sf_bbox_to_sf)
Shift, expand, or contract a bounding box (sf_bbox_shift, sf_bbox_expand, sf_bbox_contract)
The only functions with additional parameters are sf_bbox_to_lonlat_query and sf_bbox_dist. All other functions only take a bbox parameter.