Given a raster grid and a zoom level, find all tiles that intersect the grid extent within a standard global tiling profile (Mercator, geodetic, or native raster).

tile_spec(
  dimension,
  extent,
  zoom = 0L,
  blocksize = c(256L, 256L),
  profile = c("mercator", "geodetic", "raster"),
  crs = NA_character_,
  xyz = FALSE
)

Arguments

dimension

integer `c(ncol, nrow)` of the source raster.

extent

numeric `c(xmin, xmax, ymin, ymax)` of the source raster. Must be in the coordinate system of the chosen `profile`.

zoom

integer zoom level (0+).

blocksize

tile size in pixels, default `c(256L, 256L)`.

profile

one of `"mercator"`, `"geodetic"`, `"raster"`.

crs

CRS string, only used when `profile = "raster"`.

xyz

if `TRUE`, use XYZ tile row convention (0 at top).

Value

a data frame with columns `tile`, `tile_col`, `tile_row`, `zoom`, `xmin`, `xmax`, `ymin`, `ymax`, `ncol`, `nrow`, `crs`.

Details

Profiles: * `"mercator"` - Web Mercator (EPSG:3857), global extent +/-20037508.34 m. * `"geodetic"` - geographic coordinates (EPSG:4326), global extent +/-180, +/-90. * `"raster"` - uses the input `extent` as the full domain.

`tile_row` in the output uses TMS orientation (row 0 at the bottom) by default. Set `xyz = TRUE` for XYZ/slippy-map orientation (row 0 at the top).

See also

[tile_zoom()] to determine the appropriate zoom level.

Examples

tile_spec(c(8194, 8194), c(140, 155, -45, -30), profile = "geodetic")
#>   tile tile_col tile_row zoom xmin xmax ymin ymax ncol nrow       crs
#> 1    0        0        0    0 -180  180  -90   90  256  256 EPSG:4326

tile_spec(c(2048, 248), c(140, 155, -45, -30), zoom = 5,
          profile = "geodetic", blocksize = c(512L, 512L))
#>   tile tile_col tile_row zoom   xmin   xmax    ymin    ymax ncol nrow       crs
#> 1  796       28        7    5 135.00 146.25 -50.625 -45.000  512  512 EPSG:4326
#> 2  797       29        7    5 146.25 157.50 -50.625 -45.000  512  512 EPSG:4326
#> 3  764       28        8    5 135.00 146.25 -45.000 -39.375  512  512 EPSG:4326
#> 4  765       29        8    5 146.25 157.50 -45.000 -39.375  512  512 EPSG:4326
#> 5  732       28        9    5 135.00 146.25 -39.375 -33.750  512  512 EPSG:4326
#> 6  733       29        9    5 146.25 157.50 -39.375 -33.750  512  512 EPSG:4326
#> 7  700       28       10    5 135.00 146.25 -33.750 -28.125  512  512 EPSG:4326
#> 8  701       29       10    5 146.25 157.50 -33.750 -28.125  512  512 EPSG:4326