Add background OSM tiles
Uses rosm::osm.image()
to add background tiles. If you are publishing a map using these tiles, make sure to use the proper attribution (e.g., "Copyright OpenStreetMap contributors" when using an OpenStreetMap-based tile set).
data
An object of class GeomMapTile
(inherits from Geom
, ggproto
, gg
) of length 5.
annotation_map_tile( type = "osm", zoom = NULL, zoomin = -2, forcedownload = FALSE, cachedir = NULL, progress = c("text", "none"), quiet = TRUE, interpolate = TRUE, data = NULL, mapping = NULL, alpha = 1 ) GeomMapTile
type
: The map type (one of that returned by rosm::osm.types )zoom
: The zoom level (overrides zoomin)zoomin
: Delta on default zoom. The default value is designed to download fewer tiles than you probably want. Use -1
or 0
to increase the resolution.forcedownload
: Re-download cached tiles?cachedir
: Specify cache directoryprogress
: Use progress = "none"
to suppress progress and zoom outputquiet
: Use quiet = FALSE
to see which URLs are downloadedinterpolate
: Passed to grid::rasterGrob()
data, mapping
: Specify data and mapping to use this geom with facetsalpha
: Use to make this layer semi-transparentA ggplot2 layer
library(ggplot2) load_longlake_data(which = "longlake_waterdf") ggplot() + annotation_map_tile(zoom = 13, cachedir = system.file("rosm.cache", package = "ggspatial")) + geom_sf(data = longlake_waterdf, fill = NA, col = "grey50")
Useful links