Skip to contents

Divide the domain of raster into regular tiling, with optional overlap.

Usage

tj_divide_raster(x, n = c(2, 2), buffer = c(0, 0), open.upper = TRUE)

Arguments

x

stars raster

n

two-vector giving number of tiles per in x and y, in that order.

buffer

two-vector of buffering the sub-rasters in each direction, in raster pixels.

open.upper

Remove overlap? (TRUE)

Value

A list with st-polygons, cells, and row-col-ranges, and row-col-ranges without a buffer.

The row-col ranges are closed by default, so even with `buffer = c(0,0)` they will overlap at the ends. This can be avoided by setting `open.upper=TRUE` whence the range will not include the highest row/col, apart from the tile at the bottom row /right columns.

Cell-sets are computed from the row-col ranges.

The polygons are given by the st_bbox of `x` subindexed with the [expand.grid]'d vectors between the row-col ranges.

Details

Will operate on the row-col indices of the stars-object, with row top to bottom along y-axis, and col left to right on x axis.

The tiles will go top-bottom, left to right order in space. The buffer is on each tile, so for buffer (t,t) will lead to neighbouring tiles having 2t cell-width row and/or col in common. To get 2t+1-cell overlaps set `open.upper=FALSE`, but note then the minimum is 1-cell overlap.