bbox_at_zoom: Defines a bounding box at a specified zoom level around a set...

View source: R/General_Functions.R

bbox_at_zoomR Documentation

Defines a bounding box at a specified zoom level around a set of coordinates, useful for making maps with a consistent aspect ratio

Description

This function returns a bounding box with a constant aspect ratio. By default the zoom leve is fit to the input spatial file or the zoom level can be defined by the user and centered on the center value of the input.

Usage

bbox_at_zoom(locs, zoom_level = NULL)

Arguments

locs

An sf or sp object. The bounding box will be centered on the mid point value of bound box of this object.

zoom_level

Numeric. Specifies how zoomed in the bounding box should be, eg. 1 = whole world and 4 = 1/4 of world. Defaults to NULL, which will calculate the zoom level required to contain locs

Value

an object with class "bbox" containing four values: xmin, ymin, xmax, and ymax. Values will be in units of locs (either decimal degrees or meters).

References

Code adapted from: https://www.r-bloggers.com/2019/04/zooming-in-on-maps-with-sf-and-ggplot2/


allisonglider/seabiRds documentation built on Feb. 14, 2025, 7:37 a.m.