This function retrieves elevation data from the USGS national map API and converts it into a matrix appropriate for further usage with tools such as rayshader. It requires a functioning internet connection to retrieve data.

get_heightmap(
  bbox,
  img.width = 600,
  img.height = 600,
  lat = NULL,
  lng = NULL,
  save.tif = FALSE,
  tif.filename = NULL,
  sr_bbox = 4326,
  sr_image = 4326,
  verbose = FALSE
)

Arguments

bbox

Bounding box to download imagery for

img.width

Image width, in pixels

img.height

Image size, 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.tif

Logical: should the downloaded imagery be saved as a file?

tif.filename

If save.tif is TRUE, the filepath to save the resulting .tif to.

sr_bbox

Spatial reference code (ISO 19111) for bounding box

sr_image

Spatial reference code (ISO 19111) for image

verbose

Logical: print out debug information while trying to query the elevation map server?

Value

A matrix object containing elevation data suitable for use with mapping functions. Returned invisibly.

Examples

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