Learn R Programming

ggmap (version 2.5.2)

bb2bbox: Convert a bb specification to a bbox specification

Description

In ggmap, all maps (class ggmap) have the bb attribute, a data frame bounding box specification in terms of the bottom left and top right points of the spatial extent. This function converts this specification to a named double vector (with names left, bottom, right, top) specification that is used in some querying functions (e.g. get_stamenmap).

Usage

bb2bbox(bb)

Arguments

bb
a bounding box in bb format (see examples)

Value

  • a bounding box in bbox format (see examples)

Examples

Run this code
gc <- geocode("statue of liberty", source = "google")

googMap <- get_googlemap(center = as.numeric(gc))
(bb <- attr(googMap, "bb"))
bb2bbox(bb)

stamMap <- get_stamenmap(bb2bbox(bb))

ggmap(googMap) +
  geom_point(
    aes(x = lon, y = lat),
    data = gc, colour = "red", size = 3
  )

ggmap(stamMap) +
  geom_point(
    aes(x = lon, y = lat),
    data = gc, colour = "red", size = 3
  )

Run the code above in your browser using DataLab