tileScheme: Tile Scheme

View source: R/TileScheme.R

tileSchemeR Documentation

Tile Scheme

Description

This function aims to provide an all-in-one tool for creating tiling schemes, which includes options for overlapping buffers and methods for describing tile sizes in various ways (i.e. using either distance units or cell numbers).

Usage

tileScheme(
  x,
  dim,
  cells = FALSE,
  buffer = 0,
  spill = FALSE,
  round = NA,
  round_dir = "out",
  crs = NULL,
  origin = NULL,
  remove_empty = FALSE
)

Arguments

x

an object from which a SpatExtent can be extracted (SpatRaster, SpatVector, vector of numbers)

dim

numeric. Defines the 'x' and 'y' dimensions of each tile. By default, dimensions are in map units. If 'cells' is set to TRUE, then dimensions are in number of cells

cells

logical. If set to TRUE, dim and buffer dimensions will be in number of cells instead of map units

buffer

numeric. If set to >0, overlapping buffers will be created around each tile

spill

logical. Default is FALSE, in which case the tiling grid will be pushed inwards so that the buffers of the outer tiles are within the extent of x. If set to TRUE, the buffers will extend outside of the extent of x

round

numeric. Round the extent of the input Extent to the number of digits specified here.

round_dir

character. The direction of the rounding, either in for inwards or out for outwards.

crs

character. PROJ4 string defining output coordinate reference system (CRS). If set to NULL, the function will attempt to get a CRS from x (only works if it is a raster). Set to NA to force the output to have no CRS.

origin

numeric. Optional vector of two numbers corresponding to a pair of coordinates to which the tiling scheme will be aligned. Cannot be used in conjunction with cells. The coordinates do not need to be within the extent of x

remove_empty

logical. Default is FALSE. If set to TRUE, tiles containing only NA cell values will be removed from the tiling scheme. Can only be used when x is a Raster object.

Value

a 'tileScheme' object

Non-overlapping buffers

When processing a tiled dataset, using buffered tiles can help remove the edge effects along the individual tile borders. However, overlapping buffers generally need to be removed when recombining a series of tiles back into a single raster. Although this can be accomplished by using the unbuffered tile extent, this will also remove the buffered areas along the edge of the tile set. Once these unbuffered tiles are reassembled, the resulting raster will then be smaller than the original dataset before it was tiled.

This may not be a desirable result. The polygons located in the nbuffs slot will produce a set of polygons that correspond to the tile extents that conserve buffers only where they do not overlap onto neighboring tiles (i.e.: along the edge of the tile set). These polygons are useful for cropping out overlapping areas from buffered tiles in order to reassemble the tiles into a single raster.

Examples

## Not run: 
ts1 <- tileScheme(CHMdemo, dim = c(50,50))

ts2 <- tileScheme(CHMdemo, dim = c(100,120), cells = TRUE)

ts3 <- tileScheme(CHMdemo, dim = 40, buffer = 5, origin = c(0.5, 0.5))

## End(Not run)

andrew-plowright/TileManager documentation built on March 15, 2024, 4:43 p.m.