Skip to contents

See the documentation on Bing Static Maps for reference: https://docs.microsoft.com/en-us/bingmaps/rest-services/imagery/get-a-static-map

Usage

req_bingmapr(
  location = NULL,
  query = NULL,
  imagery = "BirdsEye",
  width = 600,
  height = 400,
  mapsize = NULL,
  zoom = 18,
  orientation = 0,
  nudge = NULL,
  key = Sys.getenv("BING_MAPS_API_KEY"),
  check = FALSE,
  .perform = TRUE,
  ...
)

get_request_url(...)

get_map_image(
  location = NULL,
  query = NULL,
  imagery = "BirdsEye",
  width = 600,
  height = 400,
  mapsize = NULL,
  zoom = 18,
  orientation = 0,
  nudge = NULL,
  key = Sys.getenv("BING_MAPS_API_KEY"),
  check = TRUE,
  strip = TRUE
)

get_map_meta(
  location = NULL,
  query = NULL,
  imagery = "BirdsEye",
  width = 600,
  height = 400,
  mapsize = NULL,
  zoom = 18,
  orientation = 0,
  nudge = NULL,
  key = Sys.getenv("BING_MAPS_API_KEY"),
  bbox = FALSE
)

Arguments

location

A sf, sfc, or bbox object (centroid point is used for location) or numeric vector in format c(latitude, longitude). Defaults to NULL.

query

String with query for location. query is ignored if a location is provided. Defaults to NULL.

imagery

String with imagery type, Default: 'BirdsEye' Supported values include:

  • Aerial: Aerial imagery.

  • AerialWithLabels: Aerial imagery with a road overlay.

  • AerialWithLabelsOnDemand: Aerial imagery with on-demand road overlay.

  • Streetside: Street-level imagery.

  • BirdsEye: Birds Eye (oblique-angle) imagery.

  • BirdsEyeWithLabels: Birds Eye (oblique-angle) imagery with a road overlay.

  • Road: Roads without additional imagery.

  • CanvasDark: A dark version of the road maps.

  • CanvasLight: A lighter version of the road maps which also has some of the details such as hill shading disabled.

  • CanvasGray: A grayscale version of the road maps

width, height, mapsize

Width and height in pixels or use mapsize to provide a vector of c(width, height). If mapsize is provided, width and height are ignored. Default: 600px width, 400px height, mapsize is NULL.

zoom

Numeric vector between 0 and 20 for imagery other than Bird's Eye maps or 18 to 22 for Bird's Eye maps. Default: 18

orientation

Orientation as a character string ("N", "E", "S", "W") or length 1 numeric vector (0,90,180,270). Other numeric orientations (from -360 to 720) are matched to the closest value, e.g. 35 to 0 or 75 to 90. Default: 0

nudge

Numeric vector in the format, c(meters to shift latitude, meters to shift longitude), e.g. c(100, 0) to shift center 100 meters in latitude. Defaults to NULL.

key

Bing Maps API Key, Default: Sys.getenv("BING_MAPS_API_KEY")

check

If TRUE, check the map metadata which returns an error if the image is unavailable. Default FALSE.

.perform

If TRUE, return results from httr2::req_perform(). If FALSE, return request.

...

Additional parameters passed to httr2::req_url_query()

strip

drop image comments and metadata

bbox

If TRUE, return a bbox class object based on the bounding box values from the map metadata. If FALSE (default), return the full JSON metadata. (get_map_meta() only)

Value

get_request_url returns the request URL for the Static Map API

get_map_image returns an image from magick::image_read

get_map_meta returns the JSON with the map metadata or a bbox for the map area

Details

Get API key from https://www.bingmapsportal.com/