Take an input grid (dimension and extent) and create a specification of the tiling for that grid within a profile.

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

tile_zoom(
  dimension,
  extent,
  blocksize = c(256L, 256L),
  profile = c("mercator", "geodetic", "raster")
)

Arguments

dimension

size in pixels ncol,nrow

extent

xmin,xmax,ymin,ymax

zoom

the zoom level, starts at 0 and can be up to 24

blocksize

size of each tile, defaults to 256x256

profile

profile domain to use, see Details

crs

crs, for raster profile

xyz

default is `FALSE`, if `TRUE` use xyz-mode (zero is at the top)

Value

data frame with tile specification, tile index, tile_col, tile_row, ncol, nrow, xmin, xmax, ymin, ymax, crs

Details

Profiles are 'mercator' or "geodetic" for global systems, or can use "raster" which will use the input grid specification as the entire domain.

'tile_row' in output is in TMS orientation (zero is at the bottom), use 'xyz' arg to switch.

Function `tile_zoom()` will return the "natural" maximum zoom level, i.e. the zoom at which the tile resolution is just below the input resolution. Note that no reprojection is done, the input extent must match the profile chosen (use 'raster' for native profile).

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(512, 512))
#>   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