| materialise_chunk | R Documentation |
Converts the sparse run/edge/line tables from burn() into a dense
matrix. With target, only the cells inside a sub-window of the
burn grid are materialised: the sparse tables are first filtered and
re-indexed by crop_burn() and only the sub-window is allocated, so
a chunk of a very large burn grid can be realised without ever
allocating the full grid.
materialise_chunk(x, fun = c("sum", "id"), target = NULL)
materialize_chunk(x, fun = c("sum", "id"), target = NULL)
x |
A |
fun |
character, the pixel function:
|
target |
optional numeric |
The sub-window is snapped outward to the burn grid's cell boundaries
(see crop_burn()), so the returned matrix covers at least target.
Use crop_burn(x, target) to recover the snapped grid's extent and
dimension (for plotting with rasterImage(), say). The
materialised chunk is identical to the corresponding sub-matrix of the
full materialisation.
A numeric matrix with dimensions nrow x ncol of the burn
grid, or of the snapped target window.
if (requireNamespace("geos", quietly = TRUE)) {
poly <- geos::as_geos_geometry("POLYGON ((1 1, 9 1, 9 9, 1 9, 1 1))")
r <- burn(poly, extent = c(0, 10, 0, 10), dimension = c(100L, 100L))
full <- materialise_chunk(r)
chunk <- materialise_chunk(r, target = c(2, 5, 3, 7))
dim(chunk)
crop_burn(r, c(2, 5, 3, 7))$extent
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.