adjacencies | R Documentation |
Functions 'bottom left', 'top left', 'bottom right', and 'top right' named by their initials, provide very low level relative positional structures for use in raster logic. These are used to traverse the divide left by area-based rasters which are inherently a discrete value across a finite element. If we want that element as part of a continuous surface we need to find local relative values for its corners. Used in quadmesh and anglr packages, and useful for calculating neighbourhood values.
bl(x)
tl(x)
br(x)
tr(x)
la(x)
ta(x)
ra(x)
ba(x)
image0(x, ...)
image1(x, ...)
text0(x, ...)
x |
matrix |
... |
arguments passed to image() |
bl, tl, br, and tr originally lived in affinity
matrix, padded by one row and one column relative to input
(m <- matrix(1:12, 3))
tl(m)
tr(m)
bl(m)
br(m)
tl(br(m))
image0(tl(br(m)))
text0(tl(br(m)))
## this gives neighbours in adjacent positions
m <- matrix(1:12, ncol = 3, byrow = TRUE)
matrix(c(t(la(m)), t(ta(m)), t(ra(m)), t(ba(m))), ncol = 4)
## this gives neighbours in all 8 adjacent and diagonal positions
image(matrix(rowMeans(matrix(c(t(la(m)), t(ta(m)), t(ra(m)),
t(ba(m)), t(bl(m)), t(tl(m)), t(br(m)), t(tr(m))), ncol = 8), na.rm = TRUE),
4, byrow = TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.