Closed mdsumner closed 4 years ago
When mapview is updated, do
tt <- tiles_mapview(extent(147.22881, 147.37782, -42.96346, -42.85105), type = "mapbox.outdoors")
Preparing to download: 16 tiles at zoom = 13 from
https://api.mapbox.com/v4/mapbox.outdoors/
and then
tt <- tiles_mapview(extent(147.22881, 147.37782, -42.96346, -42.85105), type = "mapbox.outdoors", zoom = 14)
Preparing to download: 64 tiles at zoom = 14 from
https://api.mapbox.com/v4/mapbox.outdoors/
etc.
Here's the tiles_mapview
function:
## remotes::install_github("hypertidy/ceramic")
## remotes::install_github("r-spatial/mapview@develop")
tiles_mapview <- function(x, type = "mapbox.satellite", zoom = NULL, ...) {
## we aren't loading the tiles, but they are indexed minimally in this object
if (is.null(zoom)) {
tiles <- ceramic::get_tiles_dim(x, dim = c(1024, 1024), type = type, ..., format = "png")
} else {
tiles <- ceramic::get_tiles_zoom(x, zoom = zoom, type = type, ..., format = "png")
}
dp <- file.path(ceramic::slippy_cache(), "api.mapbox.com", "v4", type)
mapview(dp, tms = FALSE)
}
library(mapview)
library(ceramic)
## it doesn't zoom in ...
tiles_mapview(raster::extent(breweries), type = "mapbox.satellite")
# Preparing to download: 9 tiles at zoom = 8 from
# https://api.mapbox.com/v4/mapbox.satellite/
## get all lower zooms (for this extent)
purrr::walk(0:9, ~get_tiles_zoom(raster::extent(breweries), zoom = .x, type = "mapbox.satellite"))
tiles_mapview(raster::extent(breweries), zoom = 10, type = "mapbox.satellite")
# Preparing to download: 64 tiles at zoom = 10 from
# https://api.mapbox.com/v4/mapbox.satellite/
## and then zoom in ...
Another example
## remotes::install_github("hypertidy/ceramic")
## remotes::install_github("r-spatial/mapview@develop")
tiles_mapview <- function(x, type = "mapbox.satellite", zoom = NULL, ...) {
## we aren't loading the tiles, but they are indexed minimally in this object
if (is.null(zoom)) {
tiles <- ceramic::get_tiles_dim(x, dim = c(1024, 1024), type = type, ..., format = "png")
} else {
tiles <- ceramic::get_tiles_zoom(x, zoom = zoom, type = type, ..., format = "png")
}
dp <- file.path(ceramic::slippy_cache(), "api.mapbox.com", "v4", type)
mapview(dp, tms = FALSE)
}
library(mapview)
library(ceramic)
ex <- raster::extent(breweries)
purrr::walk(0:11, ~get_tiles_zoom(ex, type = "mapbox.outdoors", zoom = .x))
tiles_mapview(ex, type = "mapbox.outdoors")
That extent needs about 300 tiles all up to zoom 11 (at zoom 12 it needs another 812).
EDIT: needed format = "png"!!!
Example above updated for new syntax, and required dev versions:
#remotes::install_github("r-spatial/leafem")
#remotes::install_github("r-spatial/mapview@develop")
tiles_mapview <- function(x, type = "mapbox.satellite", zoom = NULL, ...) {
## we aren't loading the tiles, but they are indexed minimally in this object
if (is.null(zoom)) {
tiles <- ceramic::get_tiles_dim(x, dim = c(1024, 1024), type = type, ..., format = "png")
} else {
tiles <- ceramic::get_tiles_zoom(x, zoom = zoom, type = type, ..., format = "png")
}
dp <- file.path(ceramic::ceramic_cache(), "api.mapbox.com", "v4", type)
mapview(dp, tms = FALSE)
}
library(mapview)
library(ceramic)
## it doesn't zoom in ...
tiles_mapview(raster::extent(breweries), type = "mapbox.satellite")
# Preparing to download: 9 tiles at zoom = 8 from
# https://api.mapbox.com/v4/mapbox.satellite/
## get all lower zooms (for this extent)
purrr::walk(0:9, ~get_tiles_zoom(raster::extent(breweries), zoom = .x, type = "mapbox.satellite"))
tiles_mapview(raster::extent(breweries), zoom = 10, type = "mapbox.satellite")
also see #20 and #32
The difference between XYZ and TMS: https://gist.github.com/tmcw/4954720
Mapview uses TMS by default, but Mapbox is XYZ
so