Obtain imagery or elevation tiles by location query. The first argument
loc
may be a spatial object (sp, raster, sf) or a 2-column matrix with a single
longitude and latitude value. Use buffer
to define a width and height to pad
around the raw longitude and latitude in metres. If loc
has an extent, then
buffer
is ignored.
read_tiles(
x,
buffer,
type = "mapbox.satellite",
crop_to_buffer = TRUE,
format = NULL,
...,
zoom = NULL,
debug = FALSE,
max_tiles = NULL,
base_url = NULL,
verbose = TRUE,
filename = ""
)
get_tiles(
x,
buffer,
type = "mapbox.satellite",
crop_to_buffer = TRUE,
format = NULL,
...,
zoom = NULL,
debug = FALSE,
max_tiles = NULL,
base_url = NULL,
verbose = TRUE
)
a longitude, latitude pair of coordinates, or a spatial object
width in metres to extend around the location, ignored if 'x' is a spatial object with extent
character string of provider imagery type (see Details)
crop to the user extent, used for creation of output objects (otherwise is padded tile extent)
tile format to use, defaults to "jpg" for Mapbox satellite imagery and "png" otherwise
arguments passed to internal function, specifically base_url
(see Details)
desired zoom for tiles, use with caution - if NULL
is chosen automatically
optionally avoid actual download, but print out what would be downloaded in non-debug mode
maximum number of tiles - if NULL
is set by zoom constraints
tile provider URL expert use only
report messages or suppress them
purely for read_tiles()
this is passed down to the the terra package function 'merge'
A list with files downloaded in character vector, a data frame of the tile indices, the zoom level used and the extent in xmin,xmax,ymin,ymax form.
get_tiles()
may be run with no arguments, and will download (and report on) the default
tile source at zoom 0. Arguments type
, zoom
(or max_tiles
), format
may be used
without setting loc
or buffer
and the entire world extent will be used. Please use with caution!
There is no maximum on what will be downloaded, but it can be interrupted at any time.
Use debug = TRUE
to avoid download and simply report on what would be done.
Available types are 'elevation-tiles-prod' for AWS elevation tiles, and 'mapbox.satellite', 'mapbox.terrain-rgb'. (The RGB terrain values are not unpacked.)
Function read_tiles()
will match what get_tiles()
does and actually build a raster object.
get_tiles_zoom get_tiles_dim get_tiles_buffer
if (!is.null(get_api_key())) {
tile_info <- get_tiles(ext(146, 147, -43, -42), type = "mapbox.satellite", zoom = 5)
}
#> Warning: no mapbox key found
#>
#> To set your Mapbox API key obtain a key from https://account.mapbox.com/access-tokens/
#>
#> 1) Run this to set for the session 'Sys.setenv(MAPBOX_API_KEY=<yourkey>)'
#>
#> OR,
#>
#> 2) To set permanently store 'MAPBOX_API_KEY=<yourkey>' in ~/.Renviron
#>
#> See 'help(ceramic::get_api_key)'