This function calls the ESRI ArcGIS API to retrieve map imagery to overlay a rayshader map object. It requires a functioning internet connection to obtain the data.

get_image_overlay(
  bbox,
  overlay = c("World_Imagery", "NatGeo_World_Map", "USA_Topo_Maps",
    "World_Physical_Map", "World_Shaded_Relief", "World_Street_Map", "World_Terrain_Base",
    "World_Topo_Map"),
  img.width = 600,
  img.height = 600,
  lat = NULL,
  lng = NULL,
  save.png = FALSE,
  png.filename = NULL,
  sr_bbox = 4326,
  sr_image = 4326
)

Arguments

bbox

The bounding box for your image.

overlay

One of the available overlays from https://services.arcgisonline.com/ArcGIS/rest/services.

img.width

Image width, in pixels

img.height

Image height, in pixels

lat

A quoted string indicating what named value in the bounding box represents latitude. If NULL, will be inferred from bounding box names.

lng

A quoted string indicating what named value in the bounding box represents longitude. If NULL, will be inferred from bounding box names.

save.png

Logical -- should the overlay image be saved?

png.filename

Filename for the overlay if save.png is TRUE.

sr_bbox

Spatial reference code (ISO 19111) for bounding box.

sr_image

Spatial reference code (ISO 19111) for image.

Value

A matrix object provided by readPNG, suitable for use with rayshader and similar mapping utilities. Returned invisibly.

Examples

if (FALSE) { bbox <- get_centroid_bounding_box(c( "lat" = 44.121268, "lng" = -73.903734 ), distance = 10 ) get_image_overlay(bbox, overlay = "World_Imagery") }