| make_chunk_index | R Documentation |
make_chunk_index() returns a matrix of xchunkoff, ychunkoff, xoff,
yoff, xsize, ysize, xmin, xmax, ymin and ymax, i.e., indexing
of potentially multi-block chunks defined on block boundaries for iterating
I/O operations over a raster. The last four columns are geospatial
coordinates of the bounding box. Note that class GDALRaster provides a
method of the same name that is more convenient to use with a dataset object.
make_chunk_index(
raster_xsize,
raster_ysize,
block_xsize,
block_ysize,
gt = c(0, 1, 0, 0, 0, 1),
max_pixels = 0
)
raster_xsize |
Integer value giving the number of raster columns. |
raster_ysize |
Integer value giving the number of raster rows. |
block_xsize |
Integer value giving the horizontal size of a raster block in number of pixels. |
block_ysize |
Integer value giving the vertical size of a raster block in number of pixels. |
gt |
A numeric vector of length six containing the affine geotransform
for the raster (defaults to |
max_pixels |
Numeric value (a whole number), optionally carrying the
|
The stand-alone function here supports the general case of chunking/tiling a
raster layout without using a dataset object. If the max_pixels argument
is set to zero, the chunks are raster blocks (the internal tiles in the case
of a tiled format). Otherwise, chunks are defined as the maximum number of
consecutive whole blocks containing <= max_pixels, that may span one or
multiple whole rows of blocks.
A numeric matrix with number of rows equal to the number of chunks,
and named columns: xchunkoff, ychunkoff, xoff, yoff, xsize,
ysize, xmin, xmax, ymin, ymax. Offsets are 0-based.
Methods make_chunk_index(), readChunk() and
writeChunk() in class GDALRaster.
Usage example in the web article GDAL Block Cache.
## chunk as one block
blocks <- make_chunk_index(raster_xsize = 156335, raster_ysize = 101538,
block_xsize = 256, block_ysize = 256,
gt = c(-2362395, 30, 0, 3267405, 0, -30),
max_pixels = 0)
nrow(blocks)
head(blocks)
tail(blocks)
## chunk as 16 consectutive blocks
chunks <- make_chunk_index(raster_xsize = 156335, raster_ysize = 101538,
block_xsize = 256, block_ysize = 256,
gt = c(-2362395, 30, 0, 3267405, 0, -30),
max_pixels = 256 * 256 * 16)
nrow(chunks)
head(chunks)
tail(chunks)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.