geo_basemap() prepares a basemap for plot_sites() and plot_geo()
without sending users to ggmap or other non-tidy tools. The default
"esri" fetches ESRI World Imagery tiles for the study bbox (cached on
disk). Other tile providers: "osm", "carto", "carto_dark",
"esri_topo". "coast" draws Natural Earth land polygons over an ocean
fill (offline). Pass a SpatRaster or file path for a custom DEM /
hillshade. Online tiles use maptiles when installed, otherwise a
small XYZ downloader. If tiles cannot be fetched, the function falls
back to "coast" with a message. Attribution stays with the tile provider.
Usage
geo_basemap(
x,
basemap = "esri",
coastline = NULL,
lon = lon,
lat = lat,
zoom = NULL,
alpha = 0.9,
crs = 4326
)Arguments
- x
An
sfobject, a bbox numeric vectorc(xmin, ymin, xmax, ymax), or a data frame with lon/lat used only to set the extent.- basemap
Basemap specification:
"esri"(default; World Imagery),"esri_topo","osm","carto","carto_dark","coast"(Natural Earth land),"none", aSpatRaster, or a file path.- coastline
Optional
sfpolygons/lines used whenbasemap = "coast".- lon, lat
Coordinate columns when
xis a plain data frame.- zoom
Optional tile zoom. When
NULL, chosen from the extent.- alpha
Opacity of raster / tile layers.
- crs
Target CRS (default EPSG:4326).
Value
A list with class tmr_geo_basemap containing ggplot2 layers and
metadata (provider, offline). Add it to a ggplot with + via
ggplot2::ggplot() helpers, or pass the same basemap value to
plot_sites() / plot_geo().
Examples
sites <- geo_example_sites("wilhelm")
bm <- geo_basemap(sites, basemap = "esri", lon = lon, lat = lat)
plot_sites(sites, lon, lat, basemap = "esri", colour = elevation_band)
