R/staticmap_getRasterBrick.R
staticmap_getRasterBrick.Rd
Uses the input coordinates to select an appropriate method to
build a raster::rasterBrick
object. It will either use the
staticmap_getStamenmapBrick()
function or the
staticmap_getEsrimapBrick()
function This can then passed as the
rasterBrick
object to the staticmap_plotRasterBrick()
function
for plotting.
staticmap_getRasterBrick( centerLon = NULL, centerLat = NULL, maptype = "world_topo", zoom = 12, width = 640, height = 640, bbox = NULL, maxTiles = 40, crs = sp::CRS("+init=epsg:4326"), tileCacheDir = tempdir() )
centerLon | Map center longitude. |
---|---|
centerLat | Map center latitude. |
maptype | Defaults to Esri Topographic
Available to select between Stamen basemaps or Esri basemaps.
Esri
|
zoom | Map zoom level. |
width | Width of image, in pixels. |
height | Height of image, in pixels. |
bbox | If you are using the Esri maps, then the |
maxTiles | Only utilized if selecting an esri basemap, specifies the maximum number of tiles to be returned. The greater the number, the slower the performance -- arbitrarily set to 20 by default. |
crs | 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 |
tileCacheDir | Optional location for cached tiles. |
A rasterBrick object which can be plotted with
staticmap_plotRasterBrick()
or raster::plotRGB()
and serve as a
base plot.
The spatial reference of the image when it is downloaded is 3857. If the crs argument is different, projecting may cause the size and extent of the image to differ very slightly from the input, on a scale of 1-2 pixels or 10^-3 degrees.
If bbox is specified and the bbox aspect ratio does not match the width/height aspect ratio the extent is resized to prevent the map image from appearing stretched, so the map extent may not match the bbox argument exactly.
if (FALSE) { # Fail gracefully if any resources are not available try({ rasterBrick <- staticmap_getRasterBrick(-122.3318, 47.668) staticmap_plotRasterBrick(rasterBrick) rasterBrick <- staticmap_getRasterBrick(-122.3318, 47.668, "world_streets", 12) staticmap_plotRasterBrick(rasterBrick) rasterBrick <- staticmap_getRasterBrick(-122.3318, 47.668, "watercolor", 12) staticmap_plotRasterBrick(rasterBrick) }, silent = FALSE) }