extract_bbox: Extract a bounding box from an object

Description Usage Arguments Value Examples

View source: R/extract.R

Description

This function is used internally by osm.plot, bmaps.plot, and osm.raster to extract a bounding box from their first argument. This allows considerable flexibility when specifying a location to map, in particular with character input (a place name that will be geocoded), and other Spatial*/Raster* objects.

Usage

1
extract_bbox(x, tolatlon = TRUE, ...)

Arguments

x

A Spatial* object, a Raster* object, an sp bounding box, an sf bounding box, or a character string that will be passed to searchbbox() (prettymapr package). Multiple strings will result in a bounding box that contains all of the geocoded bounding boxes. The last resort is calling sp::bbox() on the x.

tolatlon

Should the bounding box be un-projected to lat/lon coordinates? Only applied to Spatial and Raster objects.

...

Passed to searchbbox() if applicable

Value

A bounding box in the form of sp::bbox()

Examples

1
2
3
4
5
6
7
library(prettymapr)
ns <- makebbox(47.2, -59.7, 43.3, -66.4)
stopifnot(identical(ns, extract_bbox(ns)))


# downloads data, takes a long time to test
ns <- extract_bbox("nova scotia")

paleolimbot/rosm documentation built on July 23, 2019, 7:35 a.m.