Calculate tile extent for a given x, y tile at a zoom level.
mercator_tile_extent(tile_x, tile_y, zoom, tile_size = 256)
x coordinate of tile
y coordinate of tile
zoo level
tile dimensions (assumed square, i.e. 256x256)
A numeric vector of the spatial extent, in 'xmin', 'xmax', 'ymin', 'ymax' form.
Currently only spherical Mercator is supported.
mercator_tile_extent(2, 4, zoom = 10)
#> xmin xmax ymin ymax
#> -19959237 -19920101 19841830 19880965
global <- mercator_tile_extent(0, 0, zoom = 0)
plot(NA, xlim = global[c("xmin", "xmax")], ylim = global[c("ymin", "ymax")])
rect_plot <- function(x) rect(x["xmin"], x["ymin"], x["xmax"], x["ymax"])
rect_plot(mercator_tile_extent(1, 1, zoom = 2))
rect_plot(mercator_tile_extent(2, 1, zoom = 2))
rect_plot(mercator_tile_extent(1, 2, zoom = 2))
rect_plot(mercator_tile_extent(1, 1, zoom = 4))
rect_plot(mercator_tile_extent(2, 1, zoom = 4))
rect_plot(mercator_tile_extent(1, 2, zoom = 4))