Description Usage Arguments Value Examples
View source: R/getBasemapRaster.r
This function obtains an RGB raster from any of the available base maps in the (incredible!)
open source leaflet package. It is meant to replace - in a way - the ggmap
function, which now requires an API key with Google. It is in some ways more flexible: you
can set the lat and long limits strictly, it returns a projected raster which can be reprojected
to any other resolution, and it can access any of the remarkable diversity of high quality
mapping option at: http://leaflet-extras.github.io/leaflet-providers/preview/. Note that it
creates a "png" and "html" and places it in a given directory, and does not delete them.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | getBasemapRaster(
xmin,
xmax,
ymin,
ymax,
map.types = "Esri.WorldPhysical",
directory = ".",
filename = "basemap",
width = 1000,
height = 1000,
zoom = 1,
plotme = TRUE,
...
)
|
map.types |
Character specification for the base maps. see http://leaflet-extras.github.io/leaflet-providers/preview/ for available options. Favorites include: |
directory |
directory to save the html and png files |
filename |
name of png and html files |
zoom |
this is the zoom argument from |
plotme |
whether or not to plot the raster with |
xmin, xmax, ymin, ymax |
Limits (in longitude and latitude) of desired map raster. |
width, height |
approximate width and height of final raster; this is VERY approximate because the final raster is cropped around the desired limits and because there is some |
An RGB raster, i.e. one with three levels for each of the colors. Note, the projection of the returned raster is the Spherical Mercator (EPSG:3857) - used for global tiling and "native" to mapview (and leaflet).
1 2 3 4 5 6 | # SE Alaska
SEalaska.topo <- getBasemapRaster(-138,-130, 56, 60, "OpenTopoMap")
# for a ggPlot use this function (from RStoolbox):
ggRGB(SEalaska.topo, 1, 2, 3, coord_equal = FALSE)
# labeled DC map, high resolution
dc.natgeo <- getBasemapRaster(-77.5,-76.5, 38.5, 39.25, map.types = "Esri.NatGeoWorldMap", width = 1000, height = 1000, zoom = 8)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.