Downloads a PNG from the stamenmap tile server and creates a
raster::rasterBrick
object with layers for red, green, and blue. This
can then passed as the rasterBrick
object to the
staticmap_plotRasterBrick()
function for plotting.
Stamen maps tiles are freely available (April, 2019) and are described at the following URL:
http://maps.stamen.com/#terrain/12/37.7706/-122.3782
"These tiles are made available as part of the CityTracking project, funded by the Knight Foundation, in which Stamen is building web services and open source tools to display public data in easy-to-understand, highly visual ways."
staticmap_getStamenmapBrick(centerLon = NULL, centerLat = NULL,
maptype = "terrain", zoom = 12, width = 640, height = 640,
bbox = NULL, crs = sp::CRS("+init=epsg:4326"),
tileCacheDir = tempdir())
map center longitude
map center latitude
map type
map zoom level; corresponds to ggmap::get_map()
zoom level
width of image, in pixels
height of image, in pixels
bounding box vector (lonLo, latLo, lonHi, latHi). If not null,
centerLon
, centerLat
, and zoom
are ignored.
object of class CRS. The Coordinate Reference System (CRS) for the
returned map. If the CRS of the downloaded map does not match, it will be
projected to the specified CRS using raster::projectRaster
.
Optional location for cached tiles.
A rasterBrick object which can be plotted with
staticmap_plotRasterBrick()
or raster::plotRGB()
and serve as a
base plot.
# NOT RUN {
rasterBrick <- staticmap_getStamenmapBrick(-122.3318, 47.668)
staticmap_plotRasterBrick(rasterBrick)
# }
Run the code above in your browser using DataLab