# bb

0th

Percentile

##### Bounding box generator

Swiss army knife for bounding boxes. Modify an existing bounding box or create a new bounding box from scratch. See details.

##### Usage
bb(x = NA, ext = NULL, cx = NULL, cy = NULL, width = NULL, height = NULL, xlim = NULL, ylim = NULL, relative = FALSE, current.projection = NULL, projection = NULL, as.extent = FALSE)
##### Arguments
x
One of the following:
• A shape (from class Spatial, Raster, or sf (simple features)).
• A bounding box (either 2 by 2 matrix or an Extent object).
• Open Street Map search query. The bounding is automatically generated by querying x from Open Street Map Nominatim. See geocode_OSM and http://wiki.openstreetmap.org/wiki/Nominatim.

If x is not specified, a bounding box can be created from scratch (see details).

ext
Extension factor of the bounding box. If 1, the bounding box is unchanged. Values smaller than 1 reduces the bounding box, and values larger than 1 enlarges the bounding box. This argument is a shortcut for both width and height with relative=TRUE. If a negative value is specified, then the shortest side of the bounding box (so width or height) is extended with ext, and the longest side is extended with the same absolute value. This is especially useful for bounding boxes with very low or high aspect ratios.
cx
center x coordinate
cy
center y coordinate
width
width of the bounding box. These are either absolute or relative (depending on the argument relative).
height
height of the bounding box. These are either absolute or relative (depending on the argument relative).
xlim
limits of the x-axis. These are either absolute or relative (depending on the argument relative).
ylim
limits of the y-axis. See xlim.
relative
boolean that determines whether relative values are used for width, height, xlim and ylim or absolute. If x is unspecified, relative is set to "FALSE".
current.projection
projection that corresponds to the bounding box specified by x. See get_proj4 for options.
projection
projection to transform the bounding box to. See get_proj4 for options.
as.extent
should the bounding box be returned as extent? If FALSE (default) then a matrix is returned
##### Details

An existing bounding box (defined by x) can be modified as follows:

• Using the extension factor ext.
• Changing the width and height with width and height. The argument relavitve determines whether relative or absolute values are used.
• Setting the x and y limits. The argument relavitve determines whether relative or absolute values are used.

A new bounding box can be created from scratch as follows:

• Using the extension factor ext.
• Setting the center coorinates cx and cy, together with the width and height.
• Setting the x and y limits xlim and ylim

##### Value

bounding box (see argument as.extent)

geocode_OSM

• bb
##### Examples
## Not run:
# if (require(tmap)) {
#
#     data(NLD_muni)
#     data(World)
#
#     ## get bounding box (similar to sp's function bbox)
#     bb(NLD_muni)
#
#     ## extent it by factor 1.10
#     bb(NLD_muni, ext=1.10)
#
#     ## convert to longlat
#     bb(NLD_muni, projection="longlat")
#
#     ## change existing bounding box
#     bb(NLD_muni, ext=1.5)
#     bb(NLD_muni, width=2, relative = TRUE)
#     bb(NLD_muni, xlim=c(.25, .75), ylim=c(.25, .75), relative = TRUE)
#
#     bb("Limburg", projection = "rd")
#     bb_italy <- bb("Italy", projection = "eck4")
#
#     tm_shape(World, bbox=bb_italy) + tm_polygons()
#     # shorter alternative: tm_shape(World, bbox="Italy") + tm_polygons()
# }
# ## End(Not run)

Documentation reproduced from package tmaptools, version 1.0, License: GPL-3

### Community examples

Looks like there are no examples yet.