Title: | Create Raster Tiles |
---|---|
Description: | Create raster tiles abstractly. |
Authors: | Michael D. Sumner [aut, cre] |
Maintainer: | Michael D. Sumner <[email protected]> |
License: | GPL-3 |
Version: | 0.0.2.9010 |
Built: | 2024-10-16 05:16:58 UTC |
Source: | https://github.com/hypertidy/grout |
The input may be an actual raster or a matrix. There is an assumed block size of 256x256, and the scheme will record the number of tiles in each dimension and the amount of "overlapping dangle" when the dimensions of the data don't fit neatly within the tiles.
grout(dimension, extent = NULL, blocksize = NULL, projection = NA_character_)
grout(dimension, extent = NULL, blocksize = NULL, projection = NA_character_)
dimension |
number of columns and rows of the raster grid |
extent |
extent of the raster grid xmin,xmax,ymin,ymax |
blocksize |
tile dimensions in columns (X) and rows (Y) |
projection |
the projection (crs) of the grid |
If extent is not provided the default 'xmin=0,xmax=ncol,ymin=0,ymax=nrow' is used.
The tile scheme object has print and plot methods for basic information.
See example in the README with 'wk::rct' to generate plot-able and efficient spatial objects from the scheme.
A "tile scheme" object with information about the tile spacing and extent.
## one block tile (too big) grout(c(87, 61), blocksize = c(256L, 256L)) ## more size appropriate grout(c(87, 61), blocksize = c(8, 8)) grout(c(10, 20), c(0, 1, 0, 2), blocksize = c(256, 256))
## one block tile (too big) grout(c(87, 61), blocksize = c(256L, 256L)) ## more size appropriate grout(c(87, 61), blocksize = c(8, 8)) grout(c(10, 20), c(0, 1, 0, 2), blocksize = c(256, 256))
plot tiles
## S3 method for class 'grout_tiles' plot(x, ..., add = FALSE, border = "grey", lwd = 2)
## S3 method for class 'grout_tiles' plot(x, ..., add = FALSE, border = "grey", lwd = 2)
x |
a grout [tiles()] object |
... |
arguments passed to methods |
add |
add to current plot or start a new one (default is 'FALSE', a new plot) |
border |
the colour of the tile border (default grey) |
lwd |
the width of the tile border (default = 2) |
print tiles
## S3 method for class 'grout_tiles' print(x, ...)
## S3 method for class 'grout_tiles' print(x, ...)
x |
a grout [tiles()] object |
... |
ignored |
Generate a table of tile indexes from a tiling object.
tile_index(x)
tile_index(x)
x |
tiling object, created by [tiles()] |
A data frame with
* **tile** - index, same as raster cell number * **offset_x** - column offset of tile (index column 0-based) * **offset_y** - row offset of tile (index row 0-based, relative to top row) * **ncol** number of columns in tile (the right and bottom margins may have a dangle based on block size) * **nrow** number of rows in th tile * xmin, xmax, ymin, ymax - the exent
Note that ncol,nrow is the block size *unless* the tile is part of a dangling column or row (right or bottom) where the raster doesn't fill complete tiles.
data frame, see details
tile_index(grout(c(87, 61), extent = c(0, 1, 0, 1), blocksize = c(32, 16))) ## only one tile in this weird scheme! tile_index(grout(c(61, 87), blocksize = c(61, 87)))
tile_index(grout(c(87, 61), extent = c(0, 1, 0, 1), blocksize = c(32, 16))) ## only one tile in this weird scheme! tile_index(grout(c(61, 87), blocksize = c(61, 87)))
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") )
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") )
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) |
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).
data frame with tile specification, tile index, tile_col, tile_row, ncol, nrow, xmin, xmax, ymin, ymax, crs
tile_spec(c(8194, 8194), c(140, 155, -45, -30), profile = "geodetic") tile_spec(c(2048, 248), c(140, 155, -45, -30), zoom = 5, profile = "geodetic", blocksize = c(512, 512))
tile_spec(c(8194, 8194), c(140, 155, -45, -30), profile = "geodetic") tile_spec(c(2048, 248), c(140, 155, -45, -30), zoom = 5, profile = "geodetic", blocksize = c(512, 512))