get_stamenmap: Get a Stamen Map

Description Usage Arguments Value See Also Examples

Description

get_stamenmap accesses a tile server for Stamen Maps and downloads/stitches map tiles/formats a map image. Note that Stamen maps don't cover the entire world.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
get_stamenmap(bbox = c(left = -95.80204, bottom = 29.38048, right =
  -94.92313, top = 30.14344), zoom = 10, maptype = c("terrain",
  "terrain-background", "terrain-labels", "terrain-lines", "toner",
  "toner-2010", "toner-2011", "toner-background", "toner-hybrid",
  "toner-labels", "toner-lines", "toner-lite", "watercolor"),
  crop = TRUE, messaging = FALSE, urlonly = FALSE,
  color = c("color", "bw"), force = FALSE, where = tempdir(), ...)

get_stamen_tile_download_fail_log()

retry_stamen_map_download()

Arguments

bbox

a bounding box in the format c(lowerleftlon, lowerleftlat, upperrightlon, upperrightlat).

zoom

a zoom level

maptype

terrain, terrain-background, terrain-labels, terrain-lines, toner, toner-2010, toner-2011, toner-background, toner-hybrid, toner-labels, toner-lines, toner-lite, or watercolor.

crop

crop raw map tiles to specified bounding box. if FALSE, the resulting map will more than cover the bounding box specified.

messaging

turn messaging on/off

urlonly

return url only

color

color or black-and-white (use force = TRUE if you've already downloaded the images)

force

if the map is on file, should a new map be looked up?

where

where should the file drawer be located (without terminating "/")

...

...

Value

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

See Also

http://maps.stamen.com/#watercolor, ggmap

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
## Not run:  some requires Google API key, see ?register_google; heavy network/time load


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

bbox <- c(left = -97.1268, bottom = 31.536245, right = -97.099334, top = 31.559652)

ggmap(get_stamenmap(bbox, zoom = 13))
ggmap(get_stamenmap(bbox, zoom = 14))
ggmap(get_stamenmap(bbox, zoom = 15))
ggmap(get_stamenmap(bbox, zoom = 16))


place <- "mount everest"
(google <- get_googlemap(place, zoom = 9))
ggmap(google)
bbox_everest <- c(left = 86.05, bottom = 27.21, right = 87.81, top = 28.76)
ggmap(get_stamenmap(bbox_everest, zoom = 9))



## map types
########################################

place <- "rio de janeiro"
google <- get_googlemap(place, zoom = 10)
ggmap(google)

bbox <- bb2bbox(attr(google, "bb"))

get_stamenmap(bbox, maptype = "terrain")            %>% ggmap()
get_stamenmap(bbox, maptype = "terrain-background") %>% ggmap()
get_stamenmap(bbox, maptype = "terrain-labels")     %>% ggmap()
get_stamenmap(bbox, maptype = "terrain-lines")      %>% ggmap()
get_stamenmap(bbox, maptype = "toner")              %>% ggmap()
get_stamenmap(bbox, maptype = "toner-2010")         %>% ggmap()
get_stamenmap(bbox, maptype = "toner-2011")         %>% ggmap()
get_stamenmap(bbox, maptype = "toner-background")   %>% ggmap()
get_stamenmap(bbox, maptype = "toner-hybrid")       %>% ggmap()
get_stamenmap(bbox, maptype = "toner-labels")       %>% ggmap()
get_stamenmap(bbox, maptype = "toner-lines")        %>% ggmap()
get_stamenmap(bbox, maptype = "toner-lite")         %>% ggmap()
get_stamenmap(bbox, maptype = "watercolor")         %>% ggmap()


## zoom levels
########################################

get_stamenmap(bbox, maptype = "watercolor", zoom = 11) %>% ggmap(extent = "device")
get_stamenmap(bbox, maptype = "watercolor", zoom = 12) %>% ggmap(extent = "device")
get_stamenmap(bbox, maptype = "watercolor", zoom = 13) %>% ggmap(extent = "device")
# get_stamenmap(bbox, maptype = "watercolor", zoom = 14) %>% ggmap(extent = "device")
# get_stamenmap(bbox, maptype = "watercolor", zoom = 15) %>% ggmap(extent = "device")
# get_stamenmap(bbox, maptype = "watercolor", zoom = 16) %>% ggmap(extent = "device")
# get_stamenmap(bbox, maptype = "watercolor", zoom = 17) %>% ggmap(extent = "device")
# get_stamenmap(bbox, maptype = "watercolor", zoom = 18) %>% ggmap(extent = "device")


## more examples
########################################

gc <- geocode("rio de janeiro")

get_stamenmap(bbox, zoom = 10) %>% ggmap() +
 geom_point(aes(x = lon, y = lat), data = gc, colour = "red", size = 2)

get_stamenmap(bbox, zoom = 10, crop = FALSE) %>% ggmap() +
  geom_point(aes(x = lon, y = lat), data = gc, colour = "red", size = 2)

get_stamenmap(bbox, zoom = 10, maptype = "watercolor") %>% ggmap() +
  geom_point(aes(x = lon, y = lat), data = gc, colour = "red", size = 2)

get_stamenmap(bbox, zoom = 10, maptype = "toner") %>% ggmap() +
  geom_point(aes(x = lon, y = lat), data = gc, colour = "red", size = 2)


# continental united states labels
c("left" = -125, "bottom" = 25.75, "right" = -67, "top" = 49) %>%
  get_stamenmap(zoom = 5, maptype = "toner-labels") %>%
  ggmap()




# accuracy check - white house
gc <- geocode("the white house")

qmap("the white house", zoom = 16)  +
  geom_point(aes(x = lon, y = lat), data = gc, colour = "red", size = 3)

qmap("the white house", zoom = 16, source = "stamen", maptype = "terrain")  +
  geom_point(aes(x = lon, y = lat), data = gc, colour = "red", size = 3)



## known issues
########################################

# in some cases stamen's servers will not return a tile for a given map
# this tends to happen in high-zoom situations, but it is not always
# clear why it happens. these tiles will appear as blank parts of the map.

# ggmap provides some tools to try to recover the missing tiles, but the
# servers seem pretty persistent at not providing the maps.

bbox <- c(left = -97.1268, bottom = 31.536245, right = -97.099334, top = 31.559652)
ggmap(get_stamenmap(bbox, zoom = 17))
get_stamen_tile_download_fail_log()
retry_stamen_map_download()





## End(Not run)

ggmap documentation built on May 1, 2019, 8:22 p.m.