Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

get_map

Grab a map.


Description

get_map is a smart wrapper that queries the Google Maps, OpenStreetMap, Stamen Maps or Naver Map servers for a map.

Usage

get_map(location = c(lon = -95.3632715, lat = 29.7632836),
  zoom = "auto", scale = "auto", maptype = c("terrain",
  "terrain-background", "satellite", "roadmap", "hybrid", "toner",
  "watercolor", "terrain-labels", "terrain-lines", "toner-2010",
  "toner-2011", "toner-background", "toner-hybrid", "toner-labels",
  "toner-lines", "toner-lite"), source = c("google", "osm", "stamen"),
  force = ifelse(source == "google", TRUE, FALSE), messaging = FALSE,
  urlonly = FALSE, filename = NULL, crop = TRUE, color = c("color",
  "bw"), language = "en-EN", ...)

Arguments

location

an address, longitude/latitude pair (in that order), or left/bottom/right/top bounding box

zoom

map zoom, an integer from 3 (continent) to 21 (building), default value 10 (city). openstreetmaps limits a zoom of 18, and the limit on stamen maps depends on the maptype. "auto" automatically determines the zoom for bounding box specifications, and is defaulted to 10 with center/zoom specifications. maps of the whole world currently not supported.

scale

scale argument of get_googlemap or get_openstreetmap

maptype

character string providing map theme. options available are "terrain", "terrain-background", "satellite", "roadmap", and "hybrid" (google maps), "terrain", "watercolor", and "toner" (stamen maps), or a positive integer for cloudmade maps (see ?get_cloudmademap)

source

Google Maps ("google"), OpenStreetMap ("osm"), Stamen Maps ("stamen")

force

force new map (don't use archived version)

messaging

turn messaging on/off

urlonly

return url only

filename

destination file for download (file extension added according to format). Default NULL means a random tempfile.

crop

(stamen and cloudmade maps) crop tiles to bounding box

color

color ("color") or black-and-white ("bw")

language

language for google maps

...

...

Value

a ggmap object (a classed raster object with a bounding box attribute)

Author(s)

See Also

ggmap, GetMap in package RgoogleMaps

Examples

## Not run:  some requires Google API key, see ?register_google

## basic usage
########################################

# lon-lat vectors automatically use google:
(map <- get_map(c(-97.14667, 31.5493)))
str(map)
ggmap(map)

# bounding boxes default to stamen
(map <- get_map(c(left = -97.1268, bottom = 31.536245, right = -97.099334, top = 31.559652)))
ggmap(map)

# characters default to google
(map <- get_map("orlando, florida"))
ggmap(map)


## basic usage
########################################

(map <- get_map(maptype = "roadmap"))
(map <- get_map(source = "osm"))
(map <- get_map(source = "stamen", maptype = "watercolor"))

map <- get_map(location = "texas", zoom = 6, source = "stamen")
ggmap(map, fullpage = TRUE)


## End(Not run)

ggmap

Spatial Visualization with ggplot2

v3.0.0
GPL-2
Authors
David Kahle [aut, cre] (<https://orcid.org/0000-0002-9999-1558>), Hadley Wickham [aut] (<https://orcid.org/0000-0003-4757-117X>), Scott Jackson [aut], Mikko Korpela [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.